Solved

Update Program

Posted on 2009-04-05
9
575 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
  • 3
  • 2
  • 2
9 Comments
 
LVL 27

Expert Comment

by:tliotta
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
Yes Tom,

Thanks for correcting me.

Regards,
Murph
0
 

Accepted Solution

by:
IKDIST earned 400 total points
Comment Utility
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
Comment Utility
the code is formatted terrible but it should work
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

11 Experts available now in Live!

Get 1:1 Help Now