Aug 20, 2014 - 1st set of data needs to be sorted in order to merge successfully. SORT needs 1st set of records to be sorted to perform MERGE function. Should be same as the SORT, only difference is the keyword 'MERGE' to be used. Selecting data from multiple rows into a single row. (if batchnumber can reliably be used to fetch the 2 rows needed to make a single row: select yt1.demandid, yt1.debitstatus, yt2.customer from yourtable yt1, yourtable yt2 where yt1.demandid = yt2.demandid and yt1.batchnumber = 1 and yt2.batchnumber = 2. Oracle sql combine.
The day-to-day application requirements in a corporate world that can be achieved using Utility Programs are illustrated below:1. A file has 100 records. The first 10 records need to be written to output file.//JSTEP020 EXEC PGM=ICETOOL//TOOLMSG DD SYSOUT=.//DFSMSG DD SYSOUT=.//IN1 DD DSN=MYDATA.URMI.STOPAFT,DISP=SHR//OUT1 DD SYSOUT=.//TOOLIN DD.COPY FROM(IN1) TO(OUT1) USING(CTL1)/.//CTL1CNTL DD.OPTION STOPAFT=10/.The option STOPAFT will stop reading the input file after 10th record and terminates the program. Hence, 10 records are written to output.2.
Input file has one or more records for same employee number. Write unique records to output.//STEP010 EXEC PGM=SORT//SYSOUT DD SYSOUT=.//SORTIN DD DSN=MYDATA.URMI.DUPIN,DISP=SHR//SORTOUT DD SYSOUT=.//SYSIN DD.SORT FIELDS=(1,15,ZD,A)SUM FIELDS=NONE/.SUM FIELDS=NONE removes duplicates on fields specified in SORT FIELDS. In the above example, employee number is in the field position 1,15. The output file will contain the unique employee numbers sorted in ascending order.3.
Overwrite input record content.//JSTEP010 EXEC PGM=SORT//SORTIN DD DSN= MYDATA.URMI.SAMPLE.MAIN,DISP=SHR//SORTOUT DD SYSOUT=.//SYSPRINT DD SYSOUT=.//SYSOUT DD SYSOUT=.//SYSIN DD.OPTION COPYINREC OVERLAY=(47:1,6)/.In the input file, the content in position 1,6 is overwritten to the position 47,6 and then copied to the output file. INREC OVERLAY operation is used in order to rewrite data in input file before copying to output.4. Adding a sequence number to the output file.//JSTEP010 EXEC PGM=SORT//SORTIN DD.data1data2data3/.//SORTOUT DD SYSOUT=.//SYSPRINT DD SYSOUT=.//SYSOUT DD SYSOUT=.//SYSIN DD.OPTION COPYBUILD=(1:1,5,10:SEQNUM,4,ZD,START=1000,INCR=2)/.The output will be:data1 1000data2 1002data3 10044-digit sequence number is added in output at position 10, starting at 1000 and incremented by 2 for every record.5. Adding Header/Trailer to output file.//JSTEP010 EXEC PGM=SORT//SORTIN DD.data1data2data3/.//SORTOUT DD SYSOUT=.//SYSPRINT DD SYSOUT=.//SYSOUT DD SYSOUT=.//SYSIN DD.SORT FIELDS=COPYOUTFIL REMOVECC,HEADER1=(1:C'HDR',10:X'020110131C'),TRAILER1=(1:C'TRL',TOT=(10,9,PD,TO=PD,LENGTH=9))/.The output will be:HDR 20110131data1data2data3TRL 000000003TOT calculates the number of records in the input file. HDR and TRL are added as identifiers to header/trailer, which is user defined and can be customised as per the users' needs.6.
Conditional Processing//JSTEP010 EXEC PGM=SORT//SORTIN DD.data1selectdata2data3select/.//SORTOUT DD SYSOUT=.//SYSPRINT DD SYSOUT=.//SYSOUT DD SYSOUT=.//SYSIN DD.INREC IFTHEN=(WHEN=(6,1,CH,NE,C' '),BUILD=(1:1,15),IFTHEN=(WHEN=(6,1,CH,EQ,C' '),BUILD=(1:1,5,7:C'EMPTY ')OPTION COPY/.The output will be:data1selectdata2 EMPTYdata3selectBased on the 6th position of the file, the BUILD of output file varies. If 6th position is SPACES, then text 'EMPTY' is appended to input record. Else, the input record is written to output, as-is.7. Backing up a file//JSTEP001 EXEC PGM=IEBGENER//SYSPRINT DD SYSOUT=.//SYSIN DD.//SYSOUT DD SYSOUT=.//SORTOUT DD DUMMY//SYSUT1 DD DSN=MYDATA.URMI.ORIG,DISP=SHR//SYSUT2 DD DSN=MYDATA.URMI.BACKUP,DISP=(NEW,CATLG,DELETE),// DCB=.SYSUT1,SPACE=(CYL,(50,1),RLSE)IEBGENER copies the file in SYSUT1 to file in SYSUT2. Please note that file in SYSUT2 takes the same DCB as that of the SYSUT1 in the above example.8.
I have a set of data that contains multiple rows for a given User record (for some Users, not all). Thanks for the code, Colin!
I'm getting an error message saying, 'the column 'User' of the table wasn't found' as soon as I move beyond the'Source' step. It may be with how the 'Source' (which is a spreadsheet within the same Excel workbook) is getting loaded. The 1st row says, 'Column1', 'Column2', 'Column3', etc., which may be causingthe code above to miss the Column called 'User' (maybe?) - what I would consider the Column Headers are appearing in Row #2. Here is the screen shot of what I'm describing below.
How can I get PowerQuery to understand where the 'real' Column Headersare in my data so it can interpret my data correctly?I've played around with the dataset, including deleting the row that says 'Column1', 'Column2', 'Column3', etc., but it doesn't seem to help. Hi Pat,If your Source step is similar to that in the code I provided (which the exception of the table name), I don't know how it's possible to end up with a table like that. Tables that I import from the 'Current Workbook,'always have the correct headers in place, without needing to use Transform-Use First Row As Headers (or Home- Use First Row As Headers) in the Query Editor.The only suggestion I can make is to promote the first row as headers afteryour source step, and adapt the rest of my (or Imke's) code accordingly. Hi Colin,This is great - I think its almost there. The hint to have the ExpandedTable step run via the UI instead of manual code was key - I would've never known to do that.I'm noticing in the following step the ' AddedCustom 'step is showing with values of 'Error' in every row in the column called'Rows'.
Then, the ' TableColumnPivotedColumn' step shows values of'Error' in both the 'Table' and 'Rows' columns.Finally, both the ' SortedRowsDescending' and the' RemovedAddedColumn' steps have error messages saying,'We cannot convert the value 52 to type Text. Details: Value=52; Type=Type'. Thus, I cannot add the final'ExpandedTable' step since the table itself is not generated in the last steps.Earlier in the code in the 'ChangedType' step, I define both the'Client IDs' & 'Privilege' fields as'Int64.Type' so I am not defining them as 'Text' there (or anywhere else, as far as I can tell). What needs to be tweaked to ensure that the Table that gets expanded in the final step can be generated?Thank you!