Copy a physical file using CPYFRMIMPF command

115 pts.
Tags:
Application development
AS/400
CLP
I have a file in my ifs that I need to copy to a physical file using the CPYFRMIMPF command. The file on the IFS is delimited with the ~ and I would like for each stream of data prior to the ~ to be a record in my physical file. I have tried many combinations of RCDDLM and FLDDLM having the ~ and am getting nowhere. The best I have done is getting all the records copied with blank/null values or just one record. The physical file is one one field 256 characters. The IFS file looks like this: GS*001*000001~B10*001*ADFAAF*12414~ST*001*00003 I would like for the GS, B10, and ST lines to be a record in the physical file. Can anyone help with this. Thanks, Dan

Answer Wiki

Thanks. We'll let you know when a new response is added.

Dan,

I don’t think you will get desired result using the command. What you are trying to do is copy data in 3 different formats of different lengths into a single file. At least that is what I see from your description. This would be known as a Multiple record format file which goes back to the old days when we stored records of different formats all in one file. These multiple record format files/logical files are quite unfun to deal with which why most shops don’t have them. Let me ask how you will know which records will go with one another as I don’t see a common key? Or is it a situation where it won’t matter? In any event there are several ways to deal with this especially if each of the 3 formats have the same record length. I would reccommend creating a physical file that has a record lenth equal to the length of all 3 formats combined. So based upon what I’m seeing the total records length for all 3 formats would be about 43 bytes. I didn’t actually count. I would define the fields to correspond to the data. So, The first 2 bytes would be a field named “format1ty”, length 2 alpha, the second field would be “asterisk1″, length 1 alpha, The third would be “amount1″, length 3 numeric no decimal, and so on until each field is identified. Once the physical file is created it should be no problem using the command to copy the data into this new physical file. Once this is accomplished you can use simple queries to manipulate the data into 3 separate files for each of the formats or you could write a program to disect the data into a multiple record format file as you need. Let me know if this helps. Good luck.

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Dcarney
    I am thinking that this does not contain the functionality I need...it just seemed like the command should be able to look for the ~ and write a record to the physical file....don't want anything done with the *'s....just find the ~, write a record. Dan
    115 pointsBadges:
    report
  • IdratherBEFishing
    The command will separate out single records very well as designed, however you have a multiple format record and there is more than one record separator in a single "record". More importantly, in order to use the data in a meaningful way you will need to define the data to the I-series at some point. If the data is in a known Database format you can import the data using ODBC drivers and the drivers will define the fields for you. This would be the easiest way to get the data to the I-series without much fuss. Again, Good luck.
    0 pointsBadges:
    report
  • BigKat
    maybe you'll need to write a program to preprocess the file and replace the ~ with a CR/LF. Then CPYFRMIMPF should work. this would be easier than writing a program to parse the lines and write the multiple records itself
    8,010 pointsBadges:
    report
  • kevleemor
    I'd like to add a suggestion to this discussion, using the CPYFRMIMPF command to write a single record format that has a single field. Use the RCDDLM to delimit each record, you might want to experiment with setting the FLDDLM equal to the RCDDLM. In order to use this file in a RPG/LE program you will need to create I specs to define the field positions of each field within the record. Each "record format" can be determined by specifying the GS,B1,ST positions as the record code on the I specs. Kevin
    605 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following