[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Update Program

Posted on 2009-04-05
9
Medium Priority
?
588 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

650 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