AS400 interview questions and answers-Part 10


1. Create Stream File from PF and Create PF from Stream File

 

(1) CRTDIR DIR('''/HOME/DIR1''')

(2) COPY ANY DATABASE FILE IN QTEMP AND CREATE FILE AMINEM/MAST.

(3) CPYTOIMPF FROMFILE(AMINEM/MAST) TOSTMF('/HOME/DIR1/XXX.TXT') RCDDLM(*CR)

    STRDLM(' ') FLDDLM('|')

    All records copied from file MAST in AMINEM.

(4) WRKLNK '/HOME/DIR1/XXX.TXT'  

 


Browse : /HOME/DIR1/XXX.TXT
Record :       1   of      19 by  18                      Column :    1     59 by 131
Control :
 
....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+. 
************Beginning of data**************
150  |100000000113|EUR|P00000000068
150  |100000000122|EUR|P00000000068
150  |100000000127|EUR|P00000000088
150  |100000000128|EUR|P00000000081
150  |100000000129|USD|P00000000068
150  |100000000130|EUR|P00000000089
150  |100000000132|USD|P00000000091
150  |100000000133|USD|P00000000088
150  |100000000134|EUR|P00000000096
150  |100000000135|EUR|P00000000089
150  |100000000136|EUR|P00000000093
150  |100000000137|USD|P00000000094
150  |100000000138|USD|P00000000089
150  |100000000139|USD|P00000000095
150  |100000000140|USD|P00000000087
150  |100000000142|USD|P00000000086
150  |100000000143|EUR|P00000000092
150  |100000000144|USD|P00000000088
 
F3=Exit   F10=Display Hex   F12=Cancel   F15=Services   F19=Left   F20=Right

 

(5) CREATE AN OBJECT AMINEM/MASTC WITH NORECORD AND SAME RECORD FORMAT.

(6) TO COPY RECORDS FROM STREAM FILE TO FILE AMINEM/MASTC

CPYFRMIMPF FROMSTMF('/HOME/DIR1/XXX.TXT') TOFILE(AMINEM/MASTC *FIRST) 
RCDDLM(*CR) STRDLM(' ') FLDDLM('|') DECPNT(*COMMA) 
DATFMT(*ISO) RPLNULLVAL(*FLDDFT)     

   

  19 records copied to member MASTER.    

(7) CHECK THE FILE IF IT HAS BEEN PROPERLY COPIED.

    RUNQRY *N AMINEM/MASTC 

 

***Use CPYFRMSTMF when working with a file that doesn't have fields. 
For example, a source file, a PTF cover letter, a save file, etc.

***Use CPYFRMIMPF when the text file has separate fields and 
they need to be written to a PF that has separate fields defined.

 

 

2. What is journaling? Give example of journaling?

Ans:

Journaling 

·         Journaling, generally speaking, is a process of recording activity.

·         On the iSeries, journaling refers to the process of recording object activity.

·         Journaling on the iSeries typically involves the recording of the activity related to files, namely, physical files. When a file is being journaled, activity such as file-opens, file-closes and data updates are recorded.

 

Set up journaling

 1.      Use the Create Journal Receiver (CRTJRNRCV) command to create a journal receiver.

The journal receiver is where the journal entries are actually recorded. The journal "connects" the receiver to the file.

It's a good habit to name the journal receiver the same as the journal, plus a numeric suffix such as 0 or 1.

Also, you should put journal receivers in the same library as the file.

2.      Create a journal. Use the Create Journal (CRTJRN) command to create a journal and specify the receiver created in step 1. Although you can journal multiple files to the same journal (and, in some cases, that is actually preferable), you will generally want to have a journal "serving" a single file.

3.      Start journaling the file. This is done by using the Start Journal Physical File (STRJRNPF) command. This is how you associate a file to a journal. Once the association is made, the system will record in the journal receiver a copy of any record added, updated or deleted from the file. Other activity, such as when the file is opened and closed, can also be recorded in the journal receiver if you choose by selecting the appropriate options on the STRJRNPF command.

 

 

Example of Journal:

 

Sample PF

ACLEVELID  ACORGCOD       ACCOUNTNUM   ACCURRENCY  ACNAME                             
     7        190    100,000,000,001      EUR      SURESH                             
     7        190    100,000,000,002      EUR      SHRI                               
     7        190    100,000,000,003      EUR      UPI                                
     7        190    100,000,000,004      EUR      ABHI                               
     7        190    100,000,000,005      EUR      AMI                                
     7        190    100,000,000,006      INR      NOVITA                             
********  End of data  ********             

 

 

INSERT INTO AMINEM/ACCOUNT VALUES(07, 190, 100000000008, 'KZP', 

'MANIAA')

1 rows inserted in ACCOUNT in AMINEM.

 

UPDATE AMINEM/ACCOUNT SET ACNAME = 'JANE' WHERE ACNAME ='NOVITA'

1 rows updated in ACCOUNT in AMINEM.

 

 

ACLEVELID  ACORGCOD       ACCOUNTNUM   ACCURRENCY  ACNAME                                   
     7        190    100,000,000,001      EUR      SURESH                                   
     7        190    100,000,000,002      EUR      SHRI                                     
     7        190    100,000,000,003      EUR      UPI                                      
     7        190    100,000,000,004      EUR      ABHI                                     
     7        190    100,000,000,005      EUR      AMI                                      
     7        190    100,000,000,006      INR      JANE   >>>>>>>> UPDATE FROM 'NOVITA' TO 'JAN'
     7        190    100,000,000,008      KZP      MANIAA >>>>>>> INSERTED ENTRY

 


                            Display Journal Entries

 Journal  . . . . . . :   JRN2222         Library  . . . . . . :   AMINEM      
 Largest sequence number on this screen  . . . . . . : 00000000000000000008    
 Type options, press Enter.                                                    
 5=Display entire entry                                                      


 Opt    Sequence  Code  Type  Object      Library     Job         Time         
               1   J     PR                           QPADEV000K  13:59:40     
               2   D     JF   ACCOUNT     AMINEM      QPADEV000K  14:00:21     
               3   F     JM   ACCOUNT     AMINEM      QPADEV000K  14:00:21     
               4   F     JM   ACCOUNT     AMINEM      QPADEV000K  14:00:21     
               6   R     PX   ACCOUNT     AMINEM      QPADEV000K  14:01:29     
               7   R     UB   ACCOUNT     AMINEM      QPADEV000K  14:02:22     
               8   R     UP   ACCOUNT     AMINEM      QPADEV000K  14:02:22     


 

RMVJRNCHG JRN(AMINEM/JRN2222) FILE((AMINEM/ACCOUNT)) RCVRNG(AMINEM/JRN200

1 AMINEM/JRN2001) FROMENTLRG(8) TOENTLRG(7)

1 entries removed for 1 objects.

 

 

ACLEVELID  ACORGCOD       ACCOUNTNUM   ACCURRENCY  ACNAME                 
     7        190    100,000,000,001      EUR      SURESH                 
     7        190    100,000,000,002      EUR      SHRI                   
     7        190    100,000,000,003      EUR      UPI                    
     7        190    100,000,000,004      EUR      ABHI                   
     7        190    100,000,000,005      EUR      AMI                     
     7        190    100,000,000,006      INR      NOVITA     >>>>> ROLLBACK FROM 'JANE' TO 'NOVITA'
     7        190    100,000,000,008      KZP      MANIAA                 
********  End of data  ********    

 

 

APYJRNCHG JRN(AMINEM/JRN2222) FILE((AMINEM/ACCOUNT)) RCVRNG(AMINEM/JRN200

1 AMINEM/JRN2001) FROMENTLRG(8) TOENTLRG(*LAST)

 

ACLEVELID  ACORGCOD       ACCOUNTNUM   ACCURRENCY  ACNAME                        
     7        190    100,000,000,001      EUR      SURESH                        
     7        190    100,000,000,002      EUR      SHRI                          
     7        190    100,000,000,003      EUR      UPI                           
     7        190    100,000,000,004      EUR      ABHI                          
     7        190    100,000,000,005      EUR      AMI                           
     7        190    100,000,000,006      INR      JANE    >>>>>>> BACK TO 'JANE'
     7        190    100,000,000,008      KZP      MANIAA                        
********  End of data  ********   

 

 

 

3. What are the journaling commands?

Ans:

APYJRNCHG: Uses the journal entries to apply changes that have occurred since a database file was saved or some other specified time.

CHGJRN: Use this command to change the attributes of a journal or to attach new journal receivers to a journal.

CMPJRNIMG: This command compares and lists the difference between the before-image and after-image of a record, or between the current after-image of a record and the previous after-image of the record.

CRTJRN: Use this command to create a journal.

CRTJRNRCV: Use this command to create a journal receiver.

DLTJRN: Use this command to delete a journal.

DLTJRNRCV: Use this command to delete a journal receiver.

DSPJRN: This command displays or prints the journal entries that are in the journal receivers associated with the specified journal. This command has outfile support so you can list the journal entries to a database output file for further processing or analysis.

DSPJRNRCVA: Use this command to display the attributes of a journal receiver.

ENDJRNPF: This command ends journaling for the specified physical file.

RCVJRNE: This command allows a specified user program to continuously receive journal entries one at a time as they are written to the journal. The behavior is similar to an exit program.

RMVJRNCHG: Use this command to remove changes that have occurred to a database file from a specified point in time to some previous point in time (allowed only if before-images were recorded during the time).

RTVJRNE: Use this command to retrieve a journal entry and place it in CL program variables.

SNDJRNE: Use this command to write user-defined entries to a journal (i.e., journal receiver).

STRJRNPF: Use this command to start journaling for the physical file.

WRKJRN: This command displays a menu from which you can perform many journal-related functions, such as system-assisted recovery of journaled files.

WRKJRNA: This command displays the attributes of a journal and the associated receivers.

 





 

 







User Comments:



Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy