July 15, 2004, 03:52 PM<Thiru>
Create an additional record on a HOLD file
I need help on a technique which I'm facing first time.
I have file with records like;
67688 AERT, RTRTR, RTSDF
98989 DESH, KLHRET
For a single ORDNUM, there might be more than one ORDITEM values seperated by comma (,). I want to break the ORDITEM for a ORDNUM and make a another record with the ORDNUM. The expected output will be;
Anyone has any idea, how do get it?
Thanks in advance,
July 15, 2004, 03:58 PM<kj>
I had a similar issue, but I created a view in database and created a master file for that view.
July 15, 2004, 05:28 PM<Thiru>
Thanks for your thought! But I need to do without using the view or any SQL Passthru.
Any more idea?
July 15, 2004, 05:42 PMLeah
Assuming the items are in one text file, you could use the gettok and ljust functions to strip each one into a defined field. This will get the items into fields. Then look at the MacGuyer Technique of making one record into many.
A similation I use is to take an existing file and do something like this: (QUASI CODING HERE)
DEFINE FILE AFILE
BLANK/A1 = ' ';
TABLE FILE AFILE
COMPUTE COUNTER/I2 = COUNT + COUNTER;
ON TABLE HOLD AS FSEQ FORMAT FOCUS INDEX BLANK
IF RECORDLIMIT EQ 12 (OR WHATEVER YOU NEED)
DEFINE FILE BFILE
PUT GETTOK STUFF HERE
BLANK/A1 = ' ';
TABLE FILE BFILE
PRINT ORDNUM ORDITM1 ORDITM2 .....
ON TABLE HOLD AS HOLD1
JOIN BLANK IN HOLD1 TO ALL BLANK IN FSEQ AS J1
DEFINE FILE HOLD1
ORDITM/A(however long) =
IF COUNTER EQ 1 THEN ORDITM1
ELSE IF COUNTER EQ 2 THEN ORDITM2
ELSE ...... ELSE ' ';
TABLE FILE HOLD1
PRINT ORDNUM ORDITM
WHERE ORDITM NE ' '
July 15, 2004, 05:45 PMLeah
I forgot one define in the AFILE for count
in my last post on this.
COUNT/I1 = 1;
July 15, 2004, 05:54 PM<Thiru>
Thanks for your solution! I'll try to implement this idea for my case.
July 15, 2004, 06:47 PM<Thiru>
Thank you so much for your quick solution. It really worked out well eventhough it has the static record limit. But I never mind on this now.