How to pass parameter From RPGLE to CLLE?

Tags:
AS/400
RPGLE
Hi All. I'm very new to AS/400. How do I pass parameter From RPGLE to CLLE, And also how do I retrieve parameter from CLLE to RPGLE in the same program? For that what are the declaration we need in both programs. I tried simple program but is shows the error like "Pointer or parameter error"(error code 0222) I have attached my coding:
RPGLE 

DERROR            S              1A

C     'FILE NAME'   DSPLY                   FNAME            10

C     PLIST1        PLIST

C PARM                    FNAME            10

C CALL      'CPROMPT'     PLIST1

C     *ENTRY        PLIST

C PARM                    ERROR

C                   IF ERROR='Y'

C     'NOT FOUND'   DSPLY

C ELSE

C     'FOUND'       DSPLY

C ENDIF

C SETON                                            LR

CLLE

PGM PARM(&FNAME)

DCL        VAR(&FNAME) TYPE(*CHAR) LEN(10)

DCL        VAR(&ERROR) TYPE(*CHAR) LEN(1) VALUE('N')

CHKOBJ     OBJ(LOGU1/&FNAME) OBJTYPE(*FILE) MBR(*FIRST)

MONMSG     MSGID(CPF9999) EXEC(CHGVAR VAR(&ERROR) +

VALUE('Y'))

IF         COND(&ERROR = 'N') THEN(DO)

DLTF FILE(LOGU1/DESCPROMPT)

DSPFFD     FILE(LOGU1/&FNAME) OUTPUT(*OUTFILE) +

OUTFILE(LOGU1/DESCPROMPT)

ENDDO

END:
ENDPGM
1

Answer Wiki

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

When using the PARM opcode to pass parameters use Factor1 to receive resulting parameters, Factor2 to send a parameter. It is recommended to use Prototyped Calls in stead of the “Old” PARM and PLIST opcodes.

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.
  • TheRealRaven
    I'd guess that the problem is the *ENTRY PLIST. It defines a ERROR parameter, and it seems as if you're somehow expecting your CL program to modify it.

    But it's an *ENTRY parameter list for the RPG program. That means that the RPG expects it to be passed as a parm when you first call the RPG program. The CL program isn't receiving it in its parm list, so it only knows it as a local CL variable.

    What exactly are you expecting ERROR to be in both the CL and the RPG?

    And as pdraebel tried to say, the RPG is written in a very old style that is many years out of date.
    35,920 pointsBadges:
    report
  • smmloganathan
    Soon i will change my rpg style to new version. And thanks its working when I used Prototyped Calls. Thanks to all.
    50 pointsBadges:
    report
  • TheRealRaven
    It can also work with PLISTs. They just need to be coded appropriately. In your case, it looks like the RPG shouldn't have an *ENTRY PLIST, and PLIST1 needs ERROR added to its list. The CL would then also need &ERROR added to its PARM() list.

    ...Assuming that that's how you want it to work.
    35,920 pointsBadges:
    report
  • smmloganathan
    I have done what you say, Yes PLIST is also works fine. And now I learned it RPG should not have *ENTRY PLIST for this program. Also I have attached my code. Really Thanks for your valuable time.

    RPGLE
    DFNAME            S             10A               
    DERROR            S              1A   INZ('N')    
     *                                                
    C     PLIST1        PLIST                         
    C                   PARM                    FNAME 
    C                   PARM                    ERROR 
     *                                                
    C     'FILE NAME'   DSPLY                   FNAME 
    C                   CALL      'CPROMPT'     PLIST1
     *                                                
    C                   IF        ERROR='Y'           
    C     'NOT FOUND'   DSPLY                         
    C                   ELSE     
    C     'FOUND'            DSPLY     
    C                   ENDIF
    C                   SETON                                            LR
    
    CLLE
    
    PGM PARM(&FNAME &ERROR)                                             
                 DCL        VAR(&FNAME) TYPE(*CHAR) LEN(10)             
                 DCL        VAR(&ERROR) TYPE(*CHAR) LEN(1)              
                 CHKOBJ     OBJ(LOGU1/&FNAME) OBJTYPE(*FILE) MBR(*FIRST)
                 MONMSG     MSGID(CPF9999) EXEC(CHGVAR VAR(&ERROR) +    
                              VALUE('Y')) 
    ENDPGM
    50 pointsBadges:
    report
  • TheRealRaven
    The only thing to consider now is the thought that you shouldn't write any new programs and use PLISTs in them. You'll probably see them in older programs, so it might be worth knowing something about them.

    But get away from using them now. Get into the habit of always using prototypes. After you have a couple of your own examples, you'll start to learn all of the ways they are used. And also get away from the old fixed-form of coding, especially in the C-specs. No new programs should use fixed-form.
    35,920 pointsBadges:
    report
  • smmloganathan
    Yes I will learn soon. Thanks for your suggestion.
    50 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.

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

Following

Share this item with your network: