Solved

Update Program

Posted on 2009-04-05
9
576 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Declare CLOB as a host variable and use it in SQL statement in PLI 4 1,364
RPG IV Socket Program - Question on sending binary command 6 1,114
Julian to gregorian in DFSORT 3 3,432
PL/I to java 4 250
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
An analysis of the phishing scam that has been affecting Google users, along with steps to take for protection, as well as what to do if you receive one of the emails.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

864 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

19 Experts available now in Live!

Get 1:1 Help Now