Data issue while transferring data From Mainframe to IBM i

Other open source tools published on ScottKlement.com
Post Reply
jaii400
Posts: 7
Joined: Wed Dec 21, 2022 1:43 pm

Data issue while transferring data From Mainframe to IBM i

Post by jaii400 »

Hi,

I have received a file from mainframe and I have to store the data in IBM i Physical File.

What I tried:
Step 1. Moved the mainframe file into IFS folder (changed the CCSID into 838)
Step 2: Move the data from IFS folder to a IBM i Physical file using CPYFRMSTMPF (From CCSID is 838 & To CCSID is 37)
Step 3: The mainframe data fields are containing data with cobol (COMP-3) format type.
The data is not getting viewed properly in physical file.
When the same is viewed in hexadecimal mode the data is seen, this is mostly happening for packed data fields.

What Needed: Best guidance/solution to move the data from mainframe to IBM i.

Thanks in advance.
jonboy49
Posts: 200
Joined: Wed Jul 28, 2021 8:18 pm

Re: Data issue while transferring data From Mainframe to IBM i

Post by jonboy49 »

What does the defintion of the file look like? Both on the mainframe side and on the IBM i?

What does the data in the IFS file look like?

And what does your CPY... command look like?

Comp-3 is packed decimal so that shouldn't be an issue.
jaii400
Posts: 7
Joined: Wed Dec 21, 2022 1:43 pm

Re: Data issue while transferring data From Mainframe to IBM i

Post by jaii400 »

What does the defintion of the file look like? Both on the mainframe side and on the IBM i?
I'm having a flat PF. I'm not aware of the file typein mainframe

What does the data in the IFS file look like?
Except packed decimal, character data looks fine.

And what does your CPY... command look like?
This is the command I tried.
From stream file . . . . . . . . > '/home/user/ABAO'

To file member or save file . . > '/QSYS.LIB/LIBRARYNAME.LIB/FILENAME.FILE/FILENAME.MBR'

Member option . . . . . . . . . > *REPLACE *NONE, *ADD, *REPLACE
Data conversion options . . . . *AUTO *AUTO, *TBL, *NONE
Stream file CCSID . . . . . . . > 838 1-65533, *STMF, *PCASCII
Database file CCSID . . . . . . > *FILE 1-65533, *FILE
Conversion table . . . . . . . .

End of line characters . . . . . > *FIXED *ALL, *CRLF, *LF, *CR...
Tab character expansion . . . . > *NO *YES, *NO
Stream file code page . . . . . *STMF 1-32767, *STMF, *PCASCII


Comp-3 is packed decimal so that shouldn't be an issue.
jonboy49
Posts: 200
Joined: Wed Jul 28, 2021 8:18 pm

Re: Data issue while transferring data From Mainframe to IBM i

Post by jonboy49 »

jaii400 wrote: Fri Dec 23, 2022 12:33 pm What does the defintion of the file look like? Both on the mainframe side and on the IBM i?
I'm having a flat PF.
I guess I am not making myself clear.

On the mainframe side I meant the COBOL definitions of the file's fields. i.e. the FD layout in the COBOL.

On the IBM side did you just do a CRTPF and define the length without DDS or if you used DDS what did it look like.

You said that the packed data does not look right - but how are you looking at it? If it is correct when you look at the hex then it has to be the way you are attempting to view it that causes the problem.
jaii400 wrote: Fri Dec 23, 2022 12:33 pm What does the data in the IFS file look like?
Except packed decimal, character data looks fine.
I meant is it a CSV file or simply a single big blob of characters?

Is this just a one-off process or is it going to be an ongoing process? If it is onetime then the way you're doing it should be adequate. If it is going to be repeated in the future there are much better ways of doing it. You could have the mainframe output a CSV and then CPY... that to a DDS or SQL defoined table on the IBM i. You could also use DDM to directly read the file from the mainframe.
jaii400
Posts: 7
Joined: Wed Dec 21, 2022 1:43 pm

Re: Data issue while transferring data From Mainframe to IBM i

Post by jaii400 »

Thanks for the response Jon,

It's a onetime activity to store some sensitive history data.

I received a excel sheet with field definitions from cobol side.
The data provided by them is in a stream format without any field separators.

The data provided by them is not CSV it is a single big blob of characters.

In the IBM i side, I tried to create flat PF matching the data length. Then used CPYFRMSTMF.
The data got moved into the flat file.
When we view the data in hexadecimal format it is showing the data.
When I'm trying to segregate the data as per their field definitions I'm facing the issue with the packed decimal data.
For the field segregations, I wrote one RPGLE in which the input file is the flat file and the output file is in the format of field definition.

Since it is a sensitive data we are not allowed to read the data from mainframe or we won't get it as a CSV file format.
jaii400
Posts: 7
Joined: Wed Dec 21, 2022 1:43 pm

Re: Data issue while transferring data From Mainframe to IBM i

Post by jaii400 »

Adding to this I tried to use CPYFRMIMPF.

I'm getting the following error.
2 - The field A in the Field Definition File is not a field in the TOFILE.

Please be noted: I created a Physical file in the data format (DDL) provided in the excel sheet.
jaii400
Posts: 7
Joined: Wed Dec 21, 2022 1:43 pm

Re: Data issue while transferring data From Mainframe to IBM i

Post by jaii400 »

Latest Update:

I tried to convert the flat file data (which is moved into IBM i using CPYFRMSTMF) into hexadecimal.

In the hexadecimal format I can see the packed data.

How to convert this hexadecimal data and move into a field which is defined as packed decimal?
jonboy49
Posts: 200
Joined: Wed Jul 28, 2021 8:18 pm

Re: Data issue while transferring data From Mainframe to IBM i

Post by jonboy49 »

You appear to be using a valid approach BUT you still haven't posted the data definition you were given OR the details of the definition you created. How can I tell what you've done wrong without the information? My guess is you have misunderstood the definitions but if you post them I can tell you for sure.
jaii400
Posts: 7
Joined: Wed Dec 21, 2022 1:43 pm

Re: Data issue while transferring data From Mainframe to IBM i

Post by jaii400 »

Jon,

Thanks a lot for you time and support.

The DDL provided by the customer was having wrong information. We created PF based on that DDL.
So, the data uploaded was not proper.

I compared the data in hexadecimal to the DDL and found this discrepancy.
It was highlighted to the customer.

I created a PF with attributes based on the hexadecimal values.
Then I wrote a simple RPGLE and defined the PF as an external data structure.
Moved the data from the IFS file to the newly created PF.

There were challenges while moving the data, finally I'm able to move the data into PF.

Merry Christmas and Happy New Year
Post Reply