I want to check some fields if any values changes then I write in to another file

320 pts.
Tags:
AS/400
AS/400 Subfiles
Can you please tell me if can we pass library name as a parameter if I declare same file for both library. It seems if i have a file in library A has a key field num,name,age a nd the file in library B has a same key field it that possible. Please help to do this to get accurate result.
0

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.

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.
  • philpl1jb

    You can.  But to help you we need to understand what you are doing.

    1. Are you using RPGILE? (as opposed to RPG/400 or COBOL). 

    2. Combining the title and question it sounds like you want to:

    2.a pass the names of two libaries to your rpg program

    2.b open the same file for input from lib_a and output to lib_b

    2.c display data from the input file in lib_a

    2.d if the data changes write it to the output file in lib_b

     

    54,090 pointsBadges:
    report
  • azohawk

    I have to agree w/ philpljb that your question is a little vague.  If what you are trying to do is  if a changes happens in the file in library A, copy that change to the file in library B, I would suggest looking at trigger programming.  Which means I understand your question a little differently than hiilpljb did.

     

    4,055 pointsBadges:
    report
  • srivijay1
    Hi, Thanks for the responses. 
    320 pointsBadges:
    report
  • srivijay1
    * Utility file in AARMSDQ1 Library                                     
      * Key: Language Id, FileName,Format Name,Sequence Number               
                                                                             
      FMLTLITTL1 IF   E           K Disk    ExtFile(WKFILE1) UsrOpn           
      F                                     Rename(MLTLITTR:MLTLITTR1)        
                                                                             
      * Utility file in AARMSDU3 Library                                     
      * Key: Language Id, FileName,Format Name,Field Name                    
                                                                             
      FMLTLITTL2 IF   E           K Disk    ExtFile(WKFILE2) UsrOpn           
      F                                     Rename(MLTLITTR:MLTLITTR2)        
      F                                     PREFIX(A_)          
      * Work File to  check the records are matched for MQJSEQ field.   
      * Key: Language Id, FileName,Format Name,Field Name               
                                                                        
      FWORKLFDU3 IF   E           K Disk    Rename(MLTLITTR:MLTLIRRR3)   
                                                                        
      * Work file to store the data                                     
      * Key: Arrival Sequence
      FWORKPFDU3 O    E             Disk    Rename(MLTLITTR:MLTLIRRR2)    
                                                                         
      * Define Variable Constant                                         
                                                                         
      DWkFile1          S             21a   Inz('MLTLITTL1')              
      DWkFile2          S             21a   Inz('MLTLITTL2')              
      DLibrary1         S             10a                                 
      DLibrary2         S             10a                                                                                              
                                                                                       
                                                              ********************************************************************

    * MAIN CALCULATION

    ********************************************************************

    /Free

    If %Open(MLTLITTL1);

    Close MLTLITTL1;

    EndIf;

    Open MLTLITTL1;

    If %Open(MLTLITTL2);

    Close MLTLITTL2;

    EndIf;

    Open MLTLITTL2;

    WKFILE1 = %Trim(%Subst(Library1:1:10)) +'/' + 'MLTLITTL1';

    WKFILE2 = %Trim(%Subst(Library2:1:10)) +'/' + 'MLTLITTl2';

    Setll *loval MLTLITTL1;

    Read MLTLITTR1;

    Dow not %Eof(MLTLITTL1);

    // Chain (MQJLANG:MQJFILNAM:MQJFRMTNAM:MQJFLD) MLTLITTR2;

    Chain (MQJLANG:MQJFILNAM:MQJFRMTNAM) MLTLITTR2;

    If %FOUND(MLTLITTL2);

    // If MQJFLD <> A_MQJFLD;

    // Eval MQJMJOB ='Change Fld';

    // Write MLTLIRRR2;

    //ELSE;

    If MQJFLDVAL <> A_MQJFLDVAL;

    MQJMJOB ='Change Val';

    Write MLTLIRRR2;

    Endif;

    If MQJSEQ <> A_MQJSEQ;

    Setll (MQJLANG:MQJFILNAM:MQJFRMTNAM)WORKLFDU3;

    If Not %Equal (WORKLFDU3);

    Eval MQJMJOB ='Change Seq';

    Write MLTLIRRR2;

    Endif;

    Endif;

    //Endif;

    Else;

    Eval MQJMJOB ='New Record';

    Write MLTLIRRR2;

    Endif;

    READ MLTLITTR1;

    Enddo;

    Close MLTLITTL1;

    Close MLTLITTL2;

    *Inlr = *on;

    *********************************************************************

    C *Inzsr Begsr

    C *Entry Plist

    C Parm Library1

    C Parm Library2

    C Endsr

    ****************** End of data ****************************************  

    Hi i attached a code, he i used different logical file so its good..but my recruitment is to use same logical file.

    320 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.

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

Following

Share this item with your network: