?
Solved

Update Program

Posted on 2009-04-05
9
Medium Priority
?
583 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 400 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 1600 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

What's worse than having your data encrypted by ransomware? Getting attacked by a so-called "wiper," which simply destroys the data and offers you no hope of ever seeing it again.
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

765 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