Re: FTP problem

L_Brignolo

Member
Re: FTP problem

Hello Michael, again:

This is an Erratum of the previous email.
When I received my copy, noticed a couple of errors.
Then, replace the previous email with this one, please.

I am sending you what I would do, assuming that you have X12-EDI.
If you have EDIFACT, or ODETTE or something else,
or not ISA/IEA enveloping, call me.

This is an RPGIII code because mostly everybody knows it.
If you need a RPG ILE version, call me.
/////////////////////////////////////////////////////////
F* Let your file be in the "one record file the size of the EDI file" kind.
F* Next is the input file definition of that file, as it came via FTP from
NT.
F* I assume that you do not receive an envelope greater that 9999 bytes;
F* if you do receive it, call me.
FFROMNT IF F 9999 DISK
F*
F* I would create an output file of 256 characters long records.
F* This is an output file definition, remember, in QTEMP, temporary.
FUNWRAPD O F 256 DISK UC
I*
I* Let the program define data storage areas.
IFROMNT NS
IIFIELD DS 19999
IDS256 DS 256
I*
I*Let define some constants.
I "CRTPF QTEMP/UNWRAPD - C C01
I " RCDLEN(256) -
I " SIZE(*NOMAX) "
I " CLRPFM UNWRAPD" C C02
I* Let go ahead with the C statements.
C CALL "QCMDEXC" LR =LessThan
C PARM C01 X50
C PARM 50 L155
C LR RETRN
C CALL "QCMDEXC" LR
C PARM C02 X50 50
C PARM 14 L155 155
C LR RETRN
C OPEN UNWRAPD LR =LessThan
C LR RETRN
C* I will let you check it out in case of
C* an error (LR) in previous statements.
C* If everything went well, now the output file shell is in QTEMP.
C*
C* Now, read the FTPed whole long record envelope.
C READ FROMNT IFIELD LR=LastRecord
C LR RETRN
C* This previous RETRN statement is only precautionary because
C* if everything goes well, you will never receive an empty file, right?
C*
C* Let us find what your partner uses for field separator.
C 1 SUBST IFIELD:4 FS 1
C Z-ADD1 P1
C DO 15
C FS SCAN IFIELD:p1 P1
C ADD 1 P1
C END
C 1 SUBSTIFIELD:p1 SS 1
C* Now you have the ISA16 in SS.
C*
C* We are ready to start parsing.
C Z-ADD1 ES 70
C DO *HIVAL NR 70
C Z-ADDES P1 70
C SS SCAN IFIELD:p1 ES LR
=LessThan
C LR RETRN
C* If LR comes along, you would have already your segments parsed.
C* No need to do anything else, then RETRN.
C*
C ADD 1 ES
C ES SUB P1 SL 30
C SL SUBSTIFIELD:p1 DS256
C WRITEUNWRAPD DS256
C MOVE *ALL' ' DS256
C END
C* After these run, you would have NR segments in your QTEMP/UNWRAPD file, I
think.
C* Next step would be for you to check thoroughly and handle QTEMP/UNWRAPD
as you need.
/////////////////////////////////////////////////////////
I am working in an Unix box right now, then I am writing these lines from
the top of my head. As I will have errors, sorry, and, you'd need to debug
the code, but I think that you got the idea now.
/////////////////////////////////////////////////////////
Regards,

Luis Brignolo.

AS400, Unix, EDI, JDE consultant.
(718)845-6777
 
Back
Top