M
Manny
Guest
I have an ask to import a text file.
Some of the contents in the text file has static occurrences and some has dynamic.
Example:
H0X004010850TPQ0030030030030032021/03/1710:34:450
H100DEVTEST01
H2PQ003003003003003
H3CP001001001001001PP002002002002002
D1DEVTEST01
D2T-010
S1100000
Out of this H0,H1,H2,H3 and S1 comes only once in a file But D1 and D2 can come multiple times.
The below works well if I have static number of contents. But this will fail if my D1 and D2 occurs multiple times.
Could any one help me with some approach to handle this ?
Continue reading...
Some of the contents in the text file has static occurrences and some has dynamic.
Example:
H0X004010850TPQ0030030030030032021/03/1710:34:450
H100DEVTEST01
H2PQ003003003003003
H3CP001001001001001PP002002002002002
D1DEVTEST01
D2T-010
S1100000
Out of this H0,H1,H2,H3 and S1 comes only once in a file But D1 and D2 can come multiple times.
The below works well if I have static number of contents. But this will fail if my D1 and D2 occurs multiple times.
Could any one help me with some approach to handle this ?
Code:
DEFINE TEMP-TABLE TT-File
FIELDS H0 AS CHAR
FIELDS H1 AS CHAR
FIELDS H2 AS CHAR
FIELDS H3 AS CHAR
FIELDS H4 AS CHAR
FIELDS D1 AS CHAR
FIELDS D2 AS CHAR
FIELDS S1 AS CHAR.
DEFINE VARIABLE W-IMPORT-FILE AS CHARACTER NO-UNDO.
DEFINE VARIABLE W-COUNT AS INTEGER NO-UNDO.
ASSIGN W-IMPORT-FILE = "C:\Temp\Manny.txt".
INPUT FROM VALUE(W-IMPORT-FILE).
ASSIGN W-COUNT = 0.
REPEAT TRANSACTION:
CREATE TT-File.
IMPORT UNFORMATTED TT-File.H0.
IMPORT UNFORMATTED TT-File.H1.
IMPORT UNFORMATTED TT-File.H2.
IMPORT UNFORMATTED TT-File.H3.
IMPORT UNFORMATTED TT-File.D1.
IMPORT UNFORMATTED TT-File.D2.
IMPORT UNFORMATTED TT-File.S1.
END.
INPUT CLOSE.
FOR EACH TT-File:
IF SUBSTRING(TT-File.H1,1,2) = "H0":U THEN
MESSAGE "Header 0 is available to parse":U.
END.
Continue reading...