RPG/400 xodstsf

265 pts.
Tags:
RPG
RPG/400
xodstsf
Below program write a records to xodstsf in two times....  I am not sure what I am missing... can you advise? 

FWDRPIK CF E WORKSTN FXODSTSF O E DISK FTFL01 UF E K DISK DORDINV S 15A D*ORD S 8A C* *IN03 DOWEQ *OFF C DOW *IN03=*OFF C EXFMT PKSCR C PKLBL CHAIN TFOOD00 C* *IN25 IFEQ *OFF C IF %FOUND(TFL01) C MOVEL ODPOOR ORDINV C* EVAL INV = %SUBST(ORDINV:8:8) C* ORD DSPLY C PKLBL SETLL TFL01 C PKLBL READE TFL01 50 C *IN50 DOWEQ *OFF C ODSTS IFEQ 'A' C MOVE 'K' ODSTS C UPDATE TFOOD00 C ENDIF C MOVEL ODITM XSALITM1 C MOVEL ODITM XSITCT1 C MOVE 40 XSSTSDT1 C WRITE XDREC1 C PKLBL READE TFL01 50 C ENDDO C ENDIF C ENDDO C RETURN C SETON LR

Answer Wiki

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

Hi,

Looks to me like your program is going through the update process after *IN03 (F3) has been pressed. Try the following change (should be in bold) :-

FWDRPIK CF E WORKSTN
FXODSTSF O E DISK
FTFL01 UF E K DISK
DORDINV S 15A
D*ORD S 8A
C* *IN03 DOWEQ *OFF
C DOW *IN03=*OFF
C EXFMT PKSCR
<b>C *IN03 IFEQ *OFF</b>
C PKLBL CHAIN TFOOD00
C* *IN25 IFEQ *OFF
C IF %FOUND(TFL01)
C MOVEL ODPOOR ORDINV
C* EVAL INV = %SUBST(ORDINV:8:8)
C* ORD DSPLY
C PKLBL SETLL TFL01
C PKLBL READE TFL01 50
C *IN50 DOWEQ *OFF
C ODSTS IFEQ ‘A’
C MOVE ‘K’ ODSTS
C UPDATE TFOOD00
C ENDIF
C MOVEL ODITM XSALITM1
C MOVEL ODITM XSITCT1
C MOVE 40 XSSTSDT1
C WRITE XDREC1
C PKLBL READE TFL01 50
C ENDDO
C ENDIF
<b>C ENDIF</b>
C ENDDO
C RETURN
C SETON LR

Regards,

Martin Gilbert.
////////////////////// — apparently we both answered at the same time

Ohhhhhhhhh – this isn’t the way I would write it but ..

This could be an area to investigate

C* *IN03 DOWEQ *OFF
C DOW *IN03=*OFF
C EXFMT PKSCR

1. Shows the screen
2. You enter a good value
3. It processes the value and writes 1 record
4. It shows the screen again
5. You press F3 – exit
6. the code continues to run to the enddo and that would write another record

Here is one option – do not process the code following if *IN03 is on
C* *IN03 DOWEQ *OFF
C DOW *IN03=*OFF
C EXFMT PKSCR
C *IN03 IFEQ *OFF

C ENDIF

Additionally I do not understand the statement
C IF %FOUND(TFL01)
— shouldn’t that be TFOOD00 ??
Phil

Hi,

Pretty much the same answer by the looks of it…Not the way I would have written it either – at the very least there’d be a subroutine to break it up a bit and it seems a bit of a mix between RPG3 and ILE. Still, I’ve seen a lot worse….

I’ve had that same problem that someone has answered at the same time as me and wiped out my answer – I guess it’s a difficult thing to cover for, unless you stop updates while someone else has the question open to update, but then maybe they leave it locked all day… Guess you can’t win.

I always find that FILENAME/RECORDFORMATNAME question a bit confusing as well. I guess it’s something we’ve inherited from older versions of RPG where we used to have to SETLL/READ/CHAIN etc with FILENAME and then UPDAT/WRITE/DELET with RECORDFORMATNAME.

I guess it has something to do with multiple format files, but I’ve never really got to grips with it.

Regards,

Martin Gilbert.

///////////////
I get messes like this when doing maintenance — older code and I want to touch it lightly — only change what’s necessary to get the job done. But there is some point where you just should “bite the bullet” and remark out the entire block and call a new procedure or subroutine and yes this would be a couple of one or the other, the higher one to manage the process and the lower one(s) to do the work. Structurally I would have an
EXFMT before the dow and a secondary EXFMT just before the enddo which eliminates the need for the If we just added.
Phil

Hi,

Everybody has their own way of coding – I always try to keep to one EXFMT, inside the loop – and then I normally use a SELECT/WHxx to determine what actions should be done after the EXFMT. I usually code a blank WHxx for the exit function key so no action is taken and use an OTHER for the enter key.

This way I only need one EXFMT and I find the SELECT/WHxx always looks quite readable and is easy to expand upon if you need more function keys later.

I’ve always tried to keep the number of places where files and record formats are used to a minimum, but not gone to the lengths of putting them in subroutines (I find that makes it difficult to follow the logic).

Regards,

Martin Gilbert.

Discuss This Question:  

 
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

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