ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

fields

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

  • fields

    Hi,


    I have 4 fields let's say fld1(2 char),fld2(4 char),fld3(3 char) fld4(8 char) and they are having their data types in CL program as Character with respective lengths as 2,4,3,8 but the moment they are passed from CL program to RPG program 2 of them get correct values (as they had been declared as static values in CL program) but remaining two fields are not getting proper values as passed from CL program.

    for example if fld3 value from CL is passed as '300' then in RPG it's received as '?3?'

    and for fld4 value from CL is passed as '18012021' then in RPG it's received as '1?8?0?1?'.

    so any idea why is it happening so and what should be done to receive correct values in RPG program as well ?


    Thanks..

  • #2
    Using the same data types and length giving this error for this statement in CL program:-


    CHGVAR VAR(&SELT1) VALUE('L@CTCD *EQ "' || &CTCD || +
    ' " *AND L@GMAB * EQ "' || &GMAB || '" *AND +
    L@BRNO *EQ "' || &L@BRNO || '" *AND +
    L@XMDT * EQ "' || &W1DATE || '"')

    CPD0712 30 Operand does not have valid type of operator.
    CPD0711 30 Operands in expression not same type.


    &CTCD,&GMAB are fixed vales defined in CL program &L@BRNO is being read from a file which has brno defined as length 3 is decimal position as 0.
    and field L@XMDT is having date field which below RPG program is sending to CL program:-


    Code:
    dToday s d
    dPrevday s d
    C eval today = %date()
    c eval Prevday = Today - %Days(1)
    c call 'DT6BK'
    C PARM Prevday
    c seton lr
    **************
    CL:-


    Code:
    PGM PARM(&PREVDAY)
    
    DCL VAR (&PREVDAY) TYPE (*CHAR) LEN(10)
    DCL VAR (&CTCD) TYPE *CHAR LEN(2) VALUE ('AB')
    DCL VAR (&GMAB) TYPE (*CHAR) LEN(4) VALUE ('HJKL')
    DCL VAR (&L@BRNO) TYPE (*CHAR) LEN(3)
    DCL VAR (&L@XMDT) TYPE (*CHAR) LEN(8)
    DCL VAR(&SELT1) TYPE(*CHAR) LEN(175)
    DCL VAR (&W1DATE) TYPE(*CHAR) LEN(8)
    DCL VAR(&P0QRY1 TYPE(*CHAR) LEN(2) VALUE('Q1')
    DCL VAR(&P0QRY2) TYPE(*CHAR) LEN(2) VALUE(''Q2')
    DCL VAR(&P0QRY3) TYPE (*CHAR) LEN(2) VALUE('Q3')
    
    DCLF FILE(SSBRCPL)
    READ: RCVF
    MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END))
    CHGVAR VAR(&L@CTCD) VALUE(&CTCD)
    CHGVAR VAR(&L@GMAB) VALUE (&GMAB)
    CHGVAR VAR(&L@XMDT) VALUE(&W1DATE)
    
    CVTDAT DATE(&PREVDAY) TOVAR(&W1DATE) FROMFMT(*ISO) +
    TOFMT(*DMYY) TOSEP(*NONE)
    
    CHGVAR VAR(&L@XMDT) VALUE (&W1DATE)
    
    IF COND (&L@BRNO *EQ ' ') THEN(DO)
    GOTO CMDLBL(READ)
    ENDDO
    
    CHGVAR VAR(&SELT1) VALUE('L@CTCD *EQ "' || &CTCD || +
    ' " *AND L@GMAB *EQ "' || &GMAB || ' " *AND +
    L@XMDT *EQ "' || &W1DATE | ' "')
    
    CHKOBJ OBJ(QTEMP/BA@IMTP) OBJTYPE(*FILE)
    MONMSG MSGID(CPF9801) EXEC(DO)
    CRTDUPOBJ OBJ (BA@IMTP) FROMLIB(*LIB) OBJTYPE(*FILE) +
    TOLIB(QTEMP) NEWOBJ(BA@IMTP) CST(*NO) +
    TRG(*NO) ACCTL(*NONE)
    
    ENDDO
    
    CALL PGM(INBA071M) PARM(&W1DATE &P0QRY1)
    
    OVRDBF FILE(BA@IMTP) TOFILE(QTEMP/BA@IMTP) +
    OVRSCOPE(*JOB) SHARE(*YES)
    OPNQRYF FILE ((QTEMP/BA@IMTP)) OPTION(*ALL) +
    QRYSLT(&SELT1) KEYFLD((L@CTCD) (L@GMAB) +
    (L@BRNO))
    CALL PGM(BN91) PARM(&L@CTCD &L@GMAB +
    &L@BRNO &L@XMDT)
    CLOF OPNID(BA@IMTP)
    DLTOVR FILE(*ALL) LVL (*JOB)
    RCLRSC
    CLRPFM FILE(QTEMP/BA@IMTP)
    
    CALL PGM(INBA071M) PARM(&W1DATE &P0QRY2)
    CALL PGM (INBA071M) PARM(&W1DATE &P0QRY3)
    
    GOTO CMDLBL(READ)
    END: ENDPGM

    Comment


    • #3
      error is coming when above CL program calls RPG program BN91 and then when RPG program receives junk values like "for example if & L@BRNO value from CL is passed as '300' then in RPG it's received as '?3?'

      and for &L@XMDT value from CL is passed as '18012021' ( which is received from above RPG program as 'PREVDAY' after subtracting 1 date from current system date in above CL program ) then in RPG it's received as '1?8?0?1?'.

      because of these junk values my RPG program is giving decimal data error and can not execute in desired way.


      Thanks..

      Comment


      • #4
        Your RPG program is passing a variable of the DATE data type. Your CL program is receiving it as a CHAR(10). Decide how you want the CL program to receive the data and make the RPG program use the same format.


        Code:
        dToday           s           d
        dPrevday         s           d
        dPrevDayChar     s          10a
        
        C eval today = %date()
        c eval Prevday = Today - %Days(1)
        c eval PrevDayChar = %char(PrevDay: *ISO)
        c call 'DT6BK'
        C PARM PREVDAY
        c eval *inlr = *on
        
        
        
        PGM PARM(&PREVDAY)
        
        DCL VAR(&PREVDAY) TYPE(*CHAR) LEN(10)

        Comment


        • #5
          Sorry, I tried to format the code, but it didn't work properly. Also, it doesn't appear I posted the right code.

          I wish I could delete and edit my posts.

          Comment


          • #6
            No issues , but this PREVDAY value i am taking it as mentioned in my previous post to get 1 date prior to current system date and wanted to use it as DDMMYYYY(without seprator ) but it comes with separator from RPG so i move it to W1DATE variable (8 length) and then trying to pass it in &L@XMDT variable then in RPG (Program name BN91) these fields are defined as followings:-


            ENTRY PLIST
            PARM L@CTCD 2
            PARM L@GMAB 4
            PARM L@BRNO 3
            PARM L@XMDT 8




            So when I debug my above RPG program(BN91) L@CTCD ,L@GMAB i get correct values as defined in my CL ( As these are defined as static values in my CL program) but these L@BRNO and L@XMDT are being received in RPG as junk values (as said earlier if L@BRNO value from CL is passed as '300' then in RPG it's received as '?3?'
            and for field L@XMDT value from CL is passed as '18012021' then in RPG it's received as '1?8?0?1?'.


            So what changes should be made in RPG to overcome this?


            Thanks

            Comment


            • #7
              This suggests there is a data type mismatch. You said that L@BRNO is a field in the file being read, but you have also defined it with a DCL in your CL program? You don't need to define file fields as DCL, they are automatically present because of the file include. I think somehow that's the problem - the CL program is actually passing the numeric L@BRNO and L@XMDT fields from the file to program BN91, instead of the character fields you defined in your CL.

              P.S. CTCD, GMAB, BRNO? I recognise those, I think I know who you are working for (I used to work there but no longer)

              Comment

              Working...
              X