Need a code in RPG/400

0 pts.
Tags:
RPG/400
As a part of training in RPG I have created a PF with two fields barcode and vendor. I have created a screen with the same fields. Now I need a code in RPG/400 that will open the screen and when values are entered it should get populated in the file.
ASKED: November 27, 2008  10:06 AM
UPDATED: June 20, 2013  7:39 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

In RPG/400 or RPGLE.

Write code like this.

F physical file name o e disk
F display file name c f e workstn

c dow *in03=*off
c exfmt record-format of a display file
c move barcod barcode
c move vendor vendar
c write record format of a physical file
c enddo
c seton lr

Now compile and call this procedure you can get, what you expect.

Good but when you press f3 it will write one extra record

c exfmt record-format of a display file
c dow *in03=*off

c move barcod barcode
c move vendor vendar
c write record format of a physical file

c exfmt record-format of a display file

c enddo
c seton lr

phil

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • itanswers
    tried thw above code and thanks for that... now i have added another field to the same screen 'invoice'.Also i have created another file with invoice and vendor as the fields.The first file has barcode and vendor as the fields. I need a code to display on this screen the values for barcode(first file),vendor and invoice(other file) and also if any changes made update the values in respective files. I have a basic idea that is chain,display screen,read and then update.but a code would help
    0 pointsBadges:
    report
  • philpl1jb
    Right -- chain load fields -- on return check fields against file if different move data to file-fields and update. Of course you have to deal with EOF of the first file and not found of the second file. You give it a shot and we'll help.
    48,565 pointsBadges:
    report
  • Cwc
    As you're learning RPG, I would encourage you to not pick up any obsolete habits, such as the depracated operation codes like MOVE and SETON, as well as using numbered indicators. RPG is a modern and very functional language with a modern syntax. Instead of MOVE, you should use EVAL, and if you're using the free format, you can even leave that out and just do a straight assignment of one variable to another, provided the data types are compatible. As far as numbered indicators, the only time you have to use them is when using a display file for an interactive program. Even then, there is a way to map those indicators into meaningful names so that your code will read much better and be easier for others to understand in the future. The continued use of old methods will only enforce the perception among those outside the platform, including managers who make strategic decisions, that RPG is obsolete and that applications written in it should be phased out. Quite the contrary.
    4,290 pointsBadges:
    report
  • Cwc
    Sorry, I meant operation codes whose usage is being decremented, not deprecated. Here are some great tips about good coding practices in RPG.
    report
  • Cwc
    4,290 pointsBadges:
    report
  • Sloopy
    You were right first time, Cwc - the useage of certain opcodes is being deprecated. I agree with what you say, although in my company I discourage the use of free-format RPG. I do this because programmers can write incredibly untidy code in free-format, making source difficult to read and therefore to maintain, and because we have a few tools - source scanners and documentors - that rely on the fixed-format code to be able to work correctly. When we've got a style guide finalised, and the tools have been updated, and when we are up at OS version 6, then maybe we'll look at free-format in the business area. Sloopy
    2,195 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following