Solved

Creating an RPG IV Report

Posted on 2004-10-11
24
2,040 Views
Last Modified: 2007-12-19
I am working with RPG and my exeprience is very very limited so please forgive the stupid question :)

I have learned how to create a simple RPG report that has me include defining the fields of the data file by position.

My question is can I do this by using a data file that I have created with the SQL query or is that considered an externally described file?

I would like to practice creating some reports but the test data I had was comprised of several files, a fdf file, a pf file, an imp file and a txt file.....that sounds like an awful lot of work to just create a Physical file?

Douglas
0
Comment
Question by:dpalme
  • 8
  • 7
  • 6
  • +2
24 Comments
 
LVL 6

Accepted Solution

by:
blkline earned 25 total points
Comment Utility
You can produce a report on a file created with SQL DDL.  To find the record layout, use:  DSPFFD filename

My questions is, why would you want to do this with a program described file?  You're better off telling the RPG program that the file is externally defined and let it get the record description from the system.  

If you are using the RPG cycle (is *ANYONE* doing this anymore?) then you can use level and matching indicators even if you are using an externally defined file.
0
 
LVL 1

Author Comment

by:dpalme
Comment Utility
Because at this point I have not learned how to tell the program that the file is externally defined :)

0
 
LVL 16

Assisted Solution

by:theo kouwenhoven
theo kouwenhoven earned 25 total points
Comment Utility
Very simple:

FMYFILE    IF   E           K DISK      

Explenation:
F - filename - Input - Fullprocedural - External discribed - Keysequence - Disk file

Or place your cursor on the line and press F4, you see the following:

  Prompt type . . .   FX      Sequence number . . .  0011.01                  
                                                                             
                File        File          End of        File                  
  Filename      Type     Designation       File       Addition       Sequence
  MYFILE         I           F                                                
  File        Limits          Record                                          
  Format    Processing     Address Type       Device                          
    E                           K             DISK                            
                                                                             
  Keywords                                Comment                            
                                                                             

Regards,

Murph
0
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
Ahhh the good old RPG cycle - I wrote a matching records program not so long ago.
happy days
0
 
LVL 1

Author Comment

by:dpalme
Comment Utility
You know I was working on some of that last night and I did get it to work except I was getting an error message that I never was able to figure out.  \I'll have to look it up and get back here later today although I do not want to waste anyones time with error checking.

   
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
Hi dpalme ,

If you have a generated file, the record and file name are possibly the same, this will give an error.

just add a rename option like this

FGENFILE   IF   E           K DISK    RENAME(GENFILE:MYREC)

format = RENAME(ExtRecname:InternalRecname)

regards,
Murph
0
 
LVL 1

Author Comment

by:dpalme
Comment Utility
Your correct and I made that correction, google was helpful with the error code, but it was still giving me an error.

I am going to re-create the table and add some test data and then write a program using the parameters you gave me and see what happens.

For now, I'm going to close this question since I did get the appropriate answers and then if I have any additional questions I'll post more questions.

Thanks for the wonderful help.....
0
 
LVL 1

Author Comment

by:dpalme
Comment Utility
Since both murphey2 and bkline gave good answers I'm going to increase the points to 50 and split them.

Thanks for the help guys!

Douglas
0
 
LVL 1

Author Comment

by:dpalme
Comment Utility
I suppose I should have asked this before I closed the question out, but is the sql query really the best way to create tables? Is is there another way to create external files?
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
Hi,

Dave is right (as always), but if you are in a development environment, you better choose one of them, I prefer the DDS method, because it's easier to set some standards, and more transparant.

0
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
Hi Murphey2
I found the answer to
http:Q_21058424.html
the subfile tab seq. You would not believe how easy it is :-)

Dave
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:dpalme
Comment Utility
I found that error, it is CPF5029, I looked it up on google but for the life of me I cannot figure out why it is bombing.

I am only using two fields out of the table....is that it?
0
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
Hi
It will help if you can post your code. We can have a look then advise.

Dave
0
 
LVL 1

Author Comment

by:dpalme
Comment Utility
    Fdrvmst    if   e           K disk    rename(drvmst:driver)
     Fqprint    o    f  132        printer

     C                   except    headings
     C                   READ      DRVMST
     C                   DOW       NOT %EOF
     C                   except    details
     C                   READ      DRVMST
     C                   ENDDO
     C                   EVAL      *INLR = *ON
     C                   RETURN

     Oqprint    e            headings       5
     O                       *date         y     11
     O                                           39 'SAMPLE REPORT'
     O                                           63 'PAGE'
     O                       PAGE                67
     O          E            HEADINGS       1
     O                                            6 'FNAME'
     O                                           30 'DOB'
     O          E            DETAILS        1
     O                       FNAME               26
     O                       DOB                 37
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
Hey dpalme,

about your remark in this question of Date: 10/12/2004 04:56PM CEST

Don't look on google, it was a compiler error, you can see it much easier (and faster):

- Compile the program,( and hold the listing)
- open your program in SEU (editor)
- Press F15 and choose option 2 (I think)
- Press enter, if the listing can't be found press F4 to show all listings and choose the last one
- you will see the listing in the botom halve of your screen

- Now !!!!!!!!!!!! >>>>> This is realy nice <<<<<<<
- go search for errors by typing *ERR on the commandline (search argument) and press F16
- the edditor shows you the first error (or warning) an also the error on the botomline of your screen
- go with the cursor to this line and pres F1
- Now you see de detailed explenation of your error.

It's a realy nice option !!!
Don't give me the points for this (its free from the house)

Regards,

0
 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
Hi dpalme,

CPF5029 is an I/O error so it has somthing to do with your file(s)

I can't check, because I'm at home and don''t have any manual here but...

I looked to the output and that looks fine to me, so what's left is the input ???
maybe some field contains invalid data Character or binary data in a packed field?
Look to your file with query to see if there are some strange values (if so, query
wlii give ++++++++++++ in the "abnormal" field

Just type:

        RUNQRY *N MyLib/drvmst and press enter


Regards,
Murph



0
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
I do not have access to my as400 so I am guessing.

1) I think that you have more than say 66 records in your file. The printer file will be set to say page 66 lines. Once you get over that loine count you will get the error.

On the printer specification
 Fqprint    o    f  132        printer
you will need the key word  OFLIND(*IN10)
*IN10 will then be set when you reach end of the page so the code will look like

     C                   Eval         *in10=*on
     C                   READ      DRVMST
     C                   DOW       NOT %EOF
     C                   If            *in10
     C                   except    details
     C                   Endif
     C                   except    details
     C                   READ      DRVMST
     C                   ENDDO
     C                   EVAL      *INLR = *ON
     C                   RETURN

Dave
0
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
ps the
OFLIND(*IN10)
this is in the column as
rename(drvmst:driver)
on the previous spec
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
Hi Again,

I just found some more info:

------------------------  CPF5029 -------------

P_R_O_B_L_E_M_:
There is an error message “CPF5029 Data mapping error on member &4”.    

C_A_U_SE_:
A data mapping error occurred on member &4 file &2 in library &3, because the data fields in record number &6, record format &7, member number &8 are in error.

S_O_L_U_T_I_O_N_:
If the record number is zero, one of the following is at fault:

· The error occurred on an attempt to put or update a record through a logical file.
· The error occurred on a group by operation.
· The error was caused by a default value.
· The error was caused by a null value in the record.  
See previously listed message CPF5035 to determine which fields are in error. Change the fields that are in error  and try the operation again.            
If the record number is not zero, the error occurred on an attempt to read an existing record from a file. See the previously listed message CPF5035 to determine which physical file fields is in error. Then either delete the record from the file or change the data in the fields that are in error. Then try your request again.                                                

C_A_U_S_E_:
The AS400 date format is Century format, which has 3 digits for the year, 2 for the month and 2 for the day. The PC is usually month (2), day (12), and year 2001. This would confuse the AS400 and ETU; therefore ETU does not understand the data type of "L" for data type DATE.

S_O_L_U_T_I_O_N_:
Change this to a standard zoned decimal number field. You may need to change the dates in Excel to Century format, and then transfer to the AS400 using P (packed) instead of L.
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
Ha Ha Ha Ha, :-)

I just realize that 3 people somewhere on the world with a total of more then 40 years experience breaking their heads over a problem in a program with no more then 20 lines, (2 years experians to understand 1 line :-), I love the IT business.

I will take a Whisky and look within an hour to the status.

Cheers.
0
 
LVL 1

Author Comment

by:dpalme
Comment Utility
I'm really lost now LOL.....why can't this be as easy as C!!!!!!!

Damn....I need to go eat and then I'll start to play with this some tonight and see if I can figure it out.

I will run that query suggestion and see if there is something there and then start working through the list.

0
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
Hey murphey2

what is really crazy is we have all this knowledge going to a 20 line program - and the question is closed.

I think we have been drinking too much Whisky :-) I am off to the loung to hijack so poor members question.
If you have not been there Click
http://www.experts-exchange.com/Miscellaneous/Lounge/

it can be quite adictive.


That apart

The problem must lie in the databse file and a datas conversion

What we need is how you created the file, what fields the file has and the definitions.
I am now guessing that you need som compile options to make the program work. These can be needded for varying length ffields etc..


Dave

0
 
LVL 27

Expert Comment

by:tliotta
Comment Utility
Yes, if this was a table created via SQL/DDL, then options at compile time can make a big difference. Note that C might have a similar problem unless compiled appropriately.

If a CREATE TABLe was used, then please post the statement. Could be handy.

Tom

(...adding another 30+ years)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this step by step tutorial with screenshots, we will show you HOW TO: Enable SSH Remote Access on a VMware vSphere Hypervisor 6.5 (ESXi 6.5). This is important if you need to enable SSH remote access for additional troubleshooting of the ESXi hos…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now