Solved

Update Program

Posted on 2009-04-05
9
579 Views
Last Modified: 2013-11-25
Hi All

First of all many thanks in advance, I am a relative newbie to RPG and I need a little help if you can?

I need to write a program that cycles down an input file that has two fields:

RECID (8N),PODID (20N)

For each record in the INPUT file, it needs to read RECID chain off to a logical file called "ORDERS" on ORD40 (8N)and update a FIELD called POD40 (20N) with the data that is in PODID.

I dont have a logical file created on the input file as it is just file that comes from an external system. I can make sure that all the programs are in the same Library.

Anyone got a sample program or structure I can use to do this?

Eventually I need to make sure this runs every hour.

Cheers
BoltonWanderer
0
Comment
Question by:BoltonWanderer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
9 Comments
 
LVL 27

Expert Comment

by:tliotta
ID: 24083137
BoltonWanderer:

Any chance of a hint about what RPG you'll be using and which platform (operating system version/release)? You use the term "logical file", so I'd guess that it's somewhere in the AS/400 line. But even that term is a little generic.

Tom
0
 
LVL 16

Assisted Solution

by:theo kouwenhoven
theo kouwenhoven earned 100 total points
ID: 24092266
Hi BoltonWanderer,

Why creating an RPG if you also can do it with SQL on the as/400?

UPDATE ORDERS SET POD40 =
   (SELECT PODID FROM INPUTfile WHERE PODID = POD40)

On this moment I'm between 2 jobs and can not use an AS400 to check so Please forgeve me if I made a syntax error.

This update statement can be included in a Query Manager Query source and included in a CL.
to run it every 30 minutes, you can scedule this cl every 30 minutes or include a delay of 1800 seconds.
Even better is to schedule the job once and change the sceduled job at the end of your CL with CHGJOBSCDE to set the new scheduled time.

Regards,
Murph



 
0
 
LVL 27

Expert Comment

by:tliotta
ID: 24092612
Murph:

I thought pretty much the same thing. I suspect it'd be a bit more like:

UPDATE ORDERS SET POD40 =
   (SELECT PODID FROM INPUTfile WHERE ORD40 = RECID)

...but that's just a "typo".

In any case, if this is mainframe or HP RPG, or even elsewhere, the solution might need to be different. And if it's really in the AS/400 line, it might be RPG II (i.e., S/36), RPG III or RPG IV.

It all depends on what the actual requirement is. Maybe it's an exercise for learning RPG, in which case a QM solution won't help.

But it's hard to tell what needs to supplied. A RPG IV version may be quite different from RPG II (or not).

Tom
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 24095194
Yes Tom,

Thanks for correcting me.

Regards,
Murph
0
 

Accepted Solution

by:
IKDIST earned 400 total points
ID: 25954302
need to write a program that cycles down an input file that has two fields:

RECID (8N),PODID (20N)

For each record in the INPUT file, it needs to read RECID chain off to a logical file called "ORDERS" on ORD40 (8N)and update a FIELD called POD40 (20N) with the data that is in PODID.


I assume you understand the basics of file declaration so I won't bore you with that
you need a key field for the logical file
looks like
      KEYNAME            KLST
                                   Kfld                                       Blah   (where blah is a field that both files have)
You can have multiple fields in this list

Set the first file as  "IF"

then the code is
                             
*loval      setll      file1
                   dou        %eof(file1)
                   Read       File1
 
       KEYNAME     chain      Logical
                   if         %found(logical)
                   eval       POD40= PODID
                   update     LOGICAL FILE RECORD NAME
 
                   enddo

Open in new window

0
 

Expert Comment

by:IKDIST
ID: 25954312
the code is formatted terrible but it should work
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 26211267
Hi Bolton Wanderer,
The solusion from is good, I would prefer a DOW instead a DOU because then the loop ends on EOF
and no other EOF test is needed (see example IKDIST)

BTW the diference between DOW and DOU is the place where the condition is tested
DOU is tested at the end so will allways be execute the loop once
DOW is tested at the begining and will not run the loop if the condition is not met.

Regards,
Murph
Example.txt
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Tips to writing out extended subfile records conditionally 11 3,587
Primary and Secndory file concept in RPGLE 1 4,056
Command Error 16 659
calling Cobol client to java application 5 260
While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
This article discusses how to implement server side field validation and display customized error messages to the client.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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