Faq

16
Which Wrkqry created a file I have a situation where there is a pf file which was the output of a Wrkqry. Now there are hundreds of wrkqry in the library, how to identify which wrkqry created this file? DSPFD/WRKOBJ is not helpful in this situation as they cannot give the wrkqry which created this file. Please help. Ans: No reverse gear in this case. When you create outfile you specify *OUTFILE in the command, there you specify the name of out file, so that is the only place from where you can know what is the outfile for this query. If you want something which tell you automatically, you need to program it, and store history in a file programatically and the from that data which query and which outfile. I am not aware of any direct way. Ans2: Try this DMPOBJ OBJ(LIBRARY/OBJNAME) OBJTYPE(*QRYDFN) It gives spool file. Then dump that spool file into flat file. Then Read that file and find the position of object name. I think this will help you. But you have to work hard on the logic part. 2.what is breakpoint? why we use breakpoint while debuging?

Transcript of Faq

Page 1: Faq

Which Wrkqry created a file

I have a situation where there is a pf file which was the output of a Wrkqry. Now there are hundreds of wrkqry in the library, how to identify which wrkqry created this file? DSPFD/WRKOBJ is not helpful in this situation as they cannot give the wrkqry which created this file. Please help.

Ans:

No reverse gear in this case.

When you create outfile you specify *OUTFILE in the command, there you specify the name of out file, so that is the only place from where you can know what is the outfile for this query.

If you want something which tell you automatically, you need to program it, and store history in a file programatically and the from that data which query and which outfile.

I am not aware of any direct way.

Ans2:

Try this

DMPOBJ OBJ(LIBRARY/OBJNAME) OBJTYPE(*QRYDFN)

It gives spool file. Then dump that spool file into flat file.

Then Read that file and find the position of object name.

I think this will help you. But you have to work hard on the logic part.

2.what is breakpoint? why we use breakpoint while debuging?

A breakpoint is a point created in debugging program. it tells the debugger to temporarily suspend execution at a certain point. When execution is suspended at a breakpoint, ur program is said to be in break mode. Entering break mode does not terminate or end the execution of your program. Execution can be resumed at any time.

3. CL program for Automate the reply msg(with "I")??

Hi friends, could you please anybody guide or provide the hint to write the CL program as below:

Page 2: Faq

Task:Automate the auto reply (with "I" - ignore), on particular job when there is a message wait.Ans:

Two good solutions to your problem:-1.http://forums.systeminetwork.com/isnetforums/showthread.php?t=27413..2.Use WRKRPYLE commandhttp://www.mcpressonline.com/forum/showthread.php?11073-Answering-Printer-messages-in-QSYSOPRand http://itknowledgeexchange.techtarget.com/itanswers/iseries-auto-respond-to-error-message/

4.How can we use commitment control without journaling a PF?

Ans:No use of commitment control without journaling.Journaling is dependent on commitment control, commitment control is independent so can be used as usual, but no use if journaling is not used.

5.How to change field length of QPRINT report

In rpg program if we are using qprint and if there is requirement to change the field value with respect to length of this report then how we can change it Ans:First change the length of field, then adjust the positioning of fields appearing after this field, if that length is more than report width, then take option 19 from WRKMBRPDM to change the report width, and then recompile the PRTF, then recompile the program......done.

6. how to e-mail reports

hi neeraj! i have generated a report in spool file and i have to mail that report what should i do?

Ans:Use SNDDST command or MIME concept. For SNDDST the user should enrolled into the system distribution directory when you do this in interactive , or you may use an user Id which is already in Sys Dist. Dir in batch job.Ans2: 1. CPYSPLF to flat file2. CPYTOPCD from flat file to PC Doc (Folder)3. SNDDST with Type - *DOC

Page 3: Faq

7. I have a load all subfile. after doing page down let say I am in a fifth page. when i pressed enter here it is going to page 1 again. how to handle this scenario ?Ans:

Use SFLRCDNBR keyword and populate the nth page sfl record number

8. What is difference between CPYF and CRTDUPOBJ

What is difference between CPYF and CRTDUPOBJ ? Ans:

you do not have any option for selection for member,record,number of record need to copy, mapping of fields, how many records should be copied in crtdupobj command it just allow you get an image of existing file with same number of record of with out record. added to above differences - cpyf command creates the new file with same reference id but crtdupobj creates new reference id.

Or

cpyf & crtdupobj

cpyf: copy file is used to copy a file with all its field and also the AUTHORITY of that file.ie both the file have the same user authority.

crtdupobj: creating a duplicate object will allow the user to provide his own (new) AUTHORITY to the duplicate object.

9. How to test dispaly file ?

I have a Errmsg feild in my display file . I want test this display file by passing error msg as paramete let say 'Press F1 to Exit ' with out using RPG code is there any way I can acheive this ? ANS:

testing a display file

put the command 'strsda'in that take the option 3:3. Test display files

10. Web page from iseries

Hi Neeraj, Long time to speak :)

Page 4: Faq

I want to know how we can get data in xml/html format from iseries. Say I have some data in mimix and i want to get that data in a web page.

Or I have seen some example where total disk space or libary space of system is coming on a web page .Ans: From windows, you need to programatically establish connection to AS400 server, and through that connection you need to fetch data from Tables, and then you need to format that data, i.e. the way we show our normal webpages from any other data base.

You can program yourself or you can buy tools which can do this for you.

Bit occupied these day, will give detailed answer on what all tools can be used. For now you can search those tools from Google :-) which can display web pages using AS400 data.

11. Diff between Move and Eval with example

I know this is an age old question but can someone give me the conclusive answer to this one for various data types. Ans: Some links to answer this question:http://systeminetwork.com/article/move-free-format-rpg-iv-part-ii.http://forums.systeminetwork.com/isnetforums/archive/index.php/t-13166.html.....MOVE can move between dissimilar data types, EVAL can not.MOVE can not be used in free-format RPG, EVAL can be used.MOVE => EVALRMOVEL => EVAL..If you want to move between dissimilar data types using EVAL you need to use the built-in functions e.g. %char, %dec, %date, etc...

12. what is as/400

my question is what is as/400?

is this an ibm product or ibm server or some thing else?

and one more question how the name as/400 derived? Ans: AS400=>Application system/400It is mid-range server from IBM (basically hardware).Then OS400 is the operating system which runs on AS400.

Page 5: Faq

Then there are other software and utilities which works under OS400 e.g. STRSEU, PDM, compilers, SDA, RLU, etc...

command "STRDBG"

strdbg...take F4 give pgm name&lib name....update production file...*yes...but before when u compiles the pgm by opt 14 debugging view should be made *souce

for debugging first we have to set the control point...ie from which line we have to start the debugging....for that take cursor on that line press "F6"...it will appear as white..now go out of the program by "F3"..

now call the pgm(ie run the pgm)...take F10. to go through each step...while you can take option 'F11' to know the value of the variable..by put cursor on that variable..

(suppose your rpg pgm call another CL pgm you can also debug that)

finaly you must use "enddbg" command

Need to convert spool file in to pf

Hi allI am very new to the programing on AS400

I just created one CL PGM on the system to automate our health check which we do manually.1)I have created a job and scheduled on daily basis, this will call my PGM where it contains the subsystem,Disk status,ASP,lines,controlles in form of spool file.

As part of the out put of my Job it will create the spool files on the system, Now I want to copy all the spool files in to PF and need to send an email to us...

so can any one guide me how can I modify my PGM to copy all the spool files in to one PF automatically and need to send an email from the system....

Ans: To copy spool file to database file:-(You can optionally use jobname/number/etc.. if required)CPYSPLF FILE(SPLFILE) TOFILE(DBFILE)..To send mail:-Use SNDDST command

Page 6: Faq

Journal Management

1. I have an Physical File for which i had started journaling before a long time ago. Now accidently i have deleted the Physical file. How can i come to know the name of the journal , in which i have journaled my file.

2. Can i Get back my file to the original state without using my backup tape.

3. If a deleted file's journal can't be predicted then how can i search the name of the journal for any existing file.

4. A journal can be attached with 250000 objects . so is there any way to extract my object's details out of the journal, the full details i.e. before and after the compilation of my Physical file.

Ans: DSPJRN JRN(MYJRN) FILE(*ALLFILE) RCVRNG(*CURCHAIN) OUTPUT(*OUTFILE) OUTFILE(QTEMP/MYOUTF) ENTDTALEN(*CALC) INCENT(*CONFIRMED)

This command will list all data in the journal to MYOUTF (outfile), and from here you can get all data of file, even if it is deleted/recompiled. You can get the data from here.

But you must know which file's data you want, otherwise i am sorry !If you don't know which file's data is to be seen, then nobody can help

Now in this outfile the entries where JOENTT='PT' will give you the data which is added to your PF being journaled.

JOENTT='UB' data before update of an existing record.JOENTT='UP' data after update of an existing record.JOENTT='DL' line deleted.

Assume and Keep

Can anyone explain me the use of Assume and Keep keywords in display file? Ans: Assume keeps the old data when a new screen is displayed.Keep keeps the old screen data on screen after the old program is finished.Both help in overlay.But assume is for a running process. where as keep is to play between two processes.

How to comapre the same file with same field SQL

Page 7: Faq

I Want to comapre the within same file one fieLd how many records are same.??In SQL/RUNQRY is it possible to findout ?

For example : FILE NAME : CUSTOMER ------PF

Field Name : F1TID

How many reocrds are equal for this field F1TID---(F1TID = F1TID)

plz provide us simplest ways.....In SQL And RUNQRY

Ans: you can use this query

select F1TID, count(*) from customerpf order by F1TID having count(*) > 1

It will give you how many same record for field F1TID

actually i didn't understand wat you want exactly...........might be it will help you..

otherwise if you want to use a same file as different one to compare anything

you can use self join ............it work as two file for single file

like...........

@HCL is correct but there is a correction in his reply:

Group By should be used here instead of Order By:

select F1TID, count(*) from customerpf GROUP BY F1TID having count(*) > 1

select a.F1TID from customerpf a,customerpf b where a.F1TID = b.F1TID

the searcing criteria may be different but by this you can imagine that there are two file which have exactly same data............

MAPFLD

What is the use of MAPFLD in OPNQRYF?

Ans:

Page 8: Faq

MAPFLD is used to create a new fields based on existing field temporarily.

Ex: We have date field in EMPFILE named as DOB. We have a requirement to process records only for the first quarter of every year.So MAPFLD used to get the MONTH part from the date field.Instead of reading all records and evaluating in RPG program, we can SELECT the records where MONTH ranges between 01 to 03.

Sample QRY:DOB Zoned 8, 0 in the file EMPFILE and date format is YYYYMMDD. We are extractracting MM from this date field.

OPNQRYF FILE((EMPFILE) QRYSLT(' Month = %range(01 03) ‘) +MAPFLD((DATEZ DOB *ZONED 8 0) (DATEA DATEZ *CHAR 8) (MONTHA + '%sst(datea 5 2)' *CHAR 2) (MONTHZ MONTHA *ZONED 2 0) (MONTH MONTHZ *DEC 2 0))

Question:-Do we have any way to read the data from two data member of a PF same time in pgm1.

Say for example:- we have a pf with 4 data member and want to read this pf in pgm1 with 2 data member only at a time with CL or overdbf in RPG4.

Ans: Create a LF over two members and use it or use EXTMBR and USROPN keywords on F-Spec

EX: Yes...we can create LF using two members of PF.

Assume you have two members MBR1 and MBR2 on File - FILEFFile IF E DISK ExtMbr(MbrName) UsrOpn

D MbrName S 10A

/Free

MbrName = 'MBR1 ;

Open(e) File ;

Read File ;Dow Not %Eof (File) ;---------------Read File ;EndDo ;

Page 9: Faq

Close(e) File ;

MbrName = 'MBR2 ;

Open(e) File ;

Read File ;Dow Not %Eof (File) ;---------------Read File ;EndDo ;

Close(e) File ;

*Inlr = *On ;

/End-Free

Regarding CPYF command......

I am copying records from file A to file B,

1) File A having 1 field with length 10 and it is a alpha Numeric field.

2) File B having 1 field with length 6 and it is also a alpha Numeric field.

File A******EmpNam: arunkumarR-----this the field in file A with length 10 record as(arunkumarR)

When Copying this to file B, I want to increase the length of the field in file B from 6 to 10 and I need the output as

File B******EmpNam: arunkumarR

*************** Is it possible, If possible means please give me the solution.Ans:

Page 10: Faq

You need to change the file B first then perform copy, thats the way.

During copy operation file description can not be changed.

how to find out the no of elements in an Array

use %ELEM built in function

what is Decimal data error? how we can resolve it?

When we have character data in a numberic field this is decimal data error.

We need to initialize numeric field with some value to get rid of it.

Other than %ELEM you need to read the array backwards and continue till you find an element which is non blank or non-zero.

CSRLOC

Cursour location keyword - CSRLOC - what is the exact purpose of this? Why do we use it? Ans:

To get or set the postion the cursor.This is useful when you want to offer pop-up window facility on fields.E.g. <F4> for showing list of permitted values on a particular field.

sql query to read nth record

Hii,

I want a sql query on db2 which read 100th to 200th record of selected record.I used rrn() but it gives the original record no. but when we will select on some where clause then i want particular record no in selected record.

How???????????

1.Can any one explain me how to define PSHBTNFLD & PSHBTNCHC in STRSDA not in DDS?

2.How to control BUTTONS (PSHBTNCHC) to come in different lines with gap not attached.......I know to control the gap using *GUTTER between swithces in d same line but I cant able to control the gap in btwn two lines

Page 11: Faq

Ans:

DDS offers limited possibilities to enter the key words. Some key words can not be entered from STRSDA and need manual intervention.

I tried to add the key words you mentioned from SDA, but could not find how to add them from SDA. :-(

IBM should offer way to add any desired keyword from SDA. :-) Or I need to learn more about SDA.

Q:How can I load more than 22,000 records through Load all subfile?I know load all having only possible with 9999 reocrds and page up and page down will be handling by system.But my program having FOLD and DROP functionality as well.Also program is on production system and it is hard to conevrt to any other subfile.Please let me how I can resolve the above issue so that my customer will see more than 9999 record(on page 10 records are displaying) on screen and he can do page up and page down.Please reply me as soon as possible with example so that I can fix it the issue.? Ans:

Hi, You need to reload the subfile, so that it loads in such a ways that user stays on the same page where he was earlier.

You can store values in subfile so that you can key to same record.

Or you can display a message to your user saying max length is reached, the screen will be reloaded when you press <Pagedown>. (some thing like this).

FOLD/DROP is no issue. The problem is that subfile can not contain more than 9999 under any circumstances. There is no way to load more than 9999 at one time. We can only create illusion.

Practically we reload the subfile after giving an error/warning/information message to the user (or sometimes without giving any message). Thats the way.

RCVJRNE

Hiii,,,,,,,

Q:I am using RCVJRNE command to retrieve the information from Journal Entry. I am getting all updates also..

Page 12: Faq

But if I compile my pf.and then retrieve the data then I am getting the information after compilation Only..

Wat I actually need is the entire info..ie, before and after compilation...Ans:have u specified RCVRNG(*CURCHAIN) and INCENT(*ALL)Can u show ur RCVRNG command string if above does not work.OrDSPJRN JRN(JRNLIB/JRN) FILE((LIB/FILE)) RCVRNG(*LIBL/FIRST *LIBL/LAST) ENTTYP(*RCD) OUTPUT(*OUTFILE) OUTFILE(MYLIB/JRNOUT) ENTDTALEN(*CALC)

I used the above command to get the journal details. As Neeraj said, we need to mention the receiver range.

Added to this if you want to see the entire details i.e file open, close etc. you need to go for ENTTYP(*ALL) instead of ENTTYP(*RCD).

Q: question on STRSQL

How to get the data from a member of a PF (not the first one) using STRSQL.I cannot do OVRDBF before using STRSQL.

Is there any other possible way? A:you can use aliasOr

1. u can use OVRDBF SHARE(*YES) with scope of *JOB.Or2. u can create alias and use that alias from STRSQL.

Orselect * from lib/pgm1 mbr2

display screen question

enter first number: ----------enter second number: ------------addition result: -----------this is my display screencan anybody write the code in rpgle for the above display

ANs:try with...

exfmt displayfile

Page 13: Faq

field1 ADD field2 field3exfmt displayfile

Regarding Window subfile

Hi,Can anybody tell me how to reduce the window size in window subfile. Ans:

reduce size of window

go to the dds of the file and find the parameters for the window subfile name.we can change their parameters.