AS/400 opcode

60 pts.
Tags:
AS/400
AS/400 programming
Spool files
Hi,
How to retrieve a specific string in a flat file (copied from spooled file) aside from using %SUBSTRING (%SST) function?


Software/Hardware used:
Software

Answer Wiki

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

Discuss This Question: 9  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
  • CharlieBrowne

    Do you want to do this with RPG, CL, SQL, COBOL???

    I'll assume RPG. Is your input file externally defined or are you using "I" specs? If you are using "I" specs, you can just specify starting and ending positions for different fields on the report.

    If you are not using "I" specs, create a DS with the same length as you single input field and then create subfields the same as describe above.,

    41,380 pointsBadges:
    report
  • CharlieBrowne

    I should have mentioned that you can create a PF with the fields all defined from your report and then do a CPYF FMTOPT(*NOCHK). You would also want to use the INCCHAR option to select only specific records.

    41,380 pointsBadges:
    report
  • TomLiotta
    Also, what is a "flat file"? Was the spooled file copied into a physical file or into a streamfile? Methods of processing would be different. -- Tom
    125,585 pointsBadges:
    report
  • iSeries400
    The spool file was copied to PF. I'm not familiar with any programming language in AS400 so I can only use CL. 

    I was able to retrieve my preferred string/field by using the WRKQRY - Define Result Fields. There's an expression where I can use the substr( ).

    Thank you guys for you kind support. I still have few questions to come as I'm switching my career from AS400 Admistrator to Developer. 


    60 pointsBadges:
    report
  • bvining

    " I’m not familiar with any programming language in AS400 so I can only use CL. "

    Don't believe that you don't know a programming language -- CL certainly qualifies as a quite good programming language. Especially if your system is reasonably current (V5R4 or higher).

    6,540 pointsBadges:
    report
  • TomLiotta

    In a CL program, you'd use DCLF to declare the file. The program would use RCVF to read each record in a loop.

    After the RCVF, the program could call the QCLSCAN API to scan variable strings for substrings. (If you have i 7.1, you can use the new %SCAN() built-in function that was added by PTF SI49061.)

    At V5R4 and later, you might use the strstr() C library function. In many cases, that can be simpler that calling QCLSCAN.

    However, it can depend on what you want to accomplish. For example, if you want to print a list of records that have that substring, you might just run the FNDSTRPDM or the FNDSTRPDM2 command. If you tell us what you need to do, we might have better ideas.

    It might be best to copy the spooled file into a streamfile and use QShell utilities. CL can call QShell functions in a couple different ways. Or a REXX procedure might also be better.

    Tom

    125,585 pointsBadges:
    report
  • iSeries400
    Thank you guys, next time I'll try all your recommendation. 
    60 pointsBadges:
    report
  • TomLiotta

    CL certainly qualifies as a quite good programming language.

    I fully and enthusiastically agree (even before V5R3/V5R4), though I've almost given up trying to convince many others. Since V5R4, it's almost a dream come true. (And if I could just figure a way to use QleGetExp...)

    Tom

    125,585 pointsBadges:
    report
  • WoodEngineer
    Perhaps the "Defined" option on the DCL statement would do what you need.  Below is an example from one of our CL programs.  Notice that the second and third variables are subsets of &WSCST20.

    DCL        VAR(&WSCST20)  TYPE(*CHAR) LEN(20)         
    DCL        VAR(&WSCST) TYPE(*CHAR) STG(*DEFINED) +    
                 LEN(10) DEFVAR(&WSCST20 1)               
    DCL        VAR(&WSCSTLIB) TYPE(*CHAR) STG(*DEFINED) + 
                 LEN(10) DEFVAR(&WSCST20 11)              

    6,715 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