ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

update file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • update file

    KEY2 KLIST
    KFLD TCVDEV
    KFLD TCCURC



    OPEN ADCMTC0P
    EVAL TCVDEV = VDEV$
    EVAL TCCURC = CURC
    KEY2 CHAIN(E) RDCMTC
    IF %found(ADCMTC0P)
    Starting Cash
    EVAL TCSTCA = #CA$H
    EVAL NTA1B$ = TCSTCA
    EVAL NTA1CC = '360'
    Cash Out
    EVAL TCCAIN = 0
    EVAL TCCAOU = 0
    update RDCMTC

    ELSE
    Starting Cash
    EVAL TCSTCA = #CA$H
    EVAL NTA1B$ = TCSTCA
    EVAL NTA1CC = '360'

    EVAL TCCAIN = 0
    EVAL TCCAOU = 0
    write(e) RDCMTC
    ENDIF



    I get a case where the current value update file sometimes it does not contain values that should, for example field value NTA1B $ = 500, but when these programs are on the run, the field value TCSTCA = 0, while its own corresponding key field of its value.

    whether there is something wrong with my logic method? please help.






    I describe the files that will be updated field value TCSTCA her.
    Field Definitions for File: XXXXXXXXXX/AXXXXXXC0P/RDCMTC
    Key Fields: 2
    K# Field From To Length Typ Description
    1A TCVDEV 1 10 10 A Virtual device name
    2A TCCURC 11 13 3 A Currency Code
    TCSTCA 14 21 15 0 P Starting Cash
    TCCAIN 22 29 15 0 P Cash In
    TCCAOU 30 37 15 0 P Cash Out


    Thanks,
    faisalfn

  • #2
    Took me the longest time to read this code because you didn't post it i fixed format and then I realized that there were no semicolons and so you were using the old RPG III style syntax. Don't know why but ... If you want help it would make it a lot easier to help if you posted readable code. Just sayin'

    I can't see an obvious error except that you should NEVER code the use of the (E) extender unless you intend to check the status of %Error afterwards. what you have effectively done here is to tell RPG not to use its default error handling because you are going to check for errors yourself. But then you don't do it! As a result the CHAIN could be failing completely and you would never know. You would then try to do a write, and again never know if it failed. I suggest you start by removing the (E) extenders and then at least will know if the problem lies elsewhere.

    Comment

    Working...
    X