Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Pass Variable from Printing Program to SAPscript

Former Member
0 Likes
5,239

Dear all,

I'm having trouble passing a variable to my SAPScript. I can't get the values to pass. What am I doing wrong?

FORM read_zpm001 TABLES IN_TAB STRUCTURE ITCSY

   OUT_TAB STRUCTURE ITCSY.

   CALL FUNCTION 'CONVERSION_EXIT_TPLNR_OUTPUT'

           EXPORTING

             INPUT  = CAUFVD-TPLNR

           IMPORTING

             OUTPUT = CAUFVD-TPLNR.

   DATA lv_t TYPE TPLNR.

   SELECT SINGLE TPLNR FROM ZPM001 INTO lv_t WHERE TPLNR EQ CAUFVD-TPLNR(14).

   IF sy-subrc EQ 0.

     READ TABLE OUT_TAB WITH KEY NAME = 'VAR1'.

     OUT_TAB-value = lv_t.

     MODIFY OUT_TAB INDEX SY-TABIX.

   ENDIF.

ENDFORM.


SAPScript:


😕   PERFORM READ_ZPM001 IN PROGRAM ZRIPRJT00_READ_ZPM001F01 USING &VAR1&

😕   ENDPERFORM.

T6 <B2>&VAR1&</>



Thank you

13 REPLIES 13
Read only

Former Member
0 Likes
2,974

Hello Tiago,

In your form you are using 'TABLES' when I think you should be using 'USING'.

Instead of passing the tables in your form parameter, you pass the field.

Regards,

Thales Schmidt

Message was edited by: Thales Schmidt

Read only

Former Member
0 Likes
2,974

Hi

If you need to change the value VAR1, this has to be moved by option CHANGING and not USING in your sapscript


:/   PERFORM READ_ZPM001 IN PROGRAM ZRIPRJT00_READ_ZPM001F01 USING &VAR1&

:/   PERFORM READ_ZPM001 IN PROGRAM ZRIPRJT00_READ_ZPM001F01 CHANGING &VAR1&

:/   ENDPERFORM

In this way the sapscript variable VAR1 will be available in OUT_TAB table of  your form:


FORM read_zpm001 TABLES IN_TAB   STRUCTURE ITCSY

                                                             OUT_TAB STRUCTURE ITCSY.

READ TABLE OUT_TAB WITH KEY NAME = 'VAR1'.

IF SY-SUBRC = 0.

   ............................................................

Max

Read only

VenuAnumayam
Participant
0 Likes
2,974

Are you saying that your print program value is not passing back to the form?

I see that you are modifying OUT_TAB in the program. But you only have a USING parameter in your Script. You don't have any CHANGING parameter to get the value back into the form.

Try do something like:

😕   PERFORM READ_ZPM001 IN PROGRAM 'ZRIPRJT00_READ_ZPM001F01'

                                                                                                           USING &VAR1&

                                                                                                           CHANGING &xxx&

😕   ENDPERFORM.

T6 <B2>&VAR1&</>

Read only

Former Member
0 Likes
2,974

I tried all your suggestions with no success

Maybe I'm complicating things here.

I just need to make a validation on my printing program and then send an OK to my form.

This is what I'm validation:

SELECT SINGLE TPLNR FROM ZPM001 INTO lv_t WHERE TPLNR EQ CAUFVD-TPLNR(14).

If it finds a match, then I want to send an OK to my form. In this case, I want to send the actual value of lv_t.

Any simpler way of doing it?

Read only

0 Likes
2,974

Hi

What do you mean?

Do you need to raise a message or to avoid the print or something else (for example to print the validation)?

Read only

0 Likes
2,974

Hi Max,

If that SELECT returns a value, I want to print specific message on my form.

Read only

0 Likes
2,974

and remember you can fine a variable in the sapscript and set the value by a form:


:/   DEFINE &OK& = '  '

:/   PERFORM READ_ZPM001 IN PROGRAM ZRIPRJT00_READ_ZPM001F01 CHANGING &OK&

:/   ENDPERFORM

:/   IF &OK& = 'X'.

      do something

:/   ELSE

:/     do something else

:/   ENDIF

Read only

pranay570708
Active Contributor
0 Likes
2,974

This message was moderated.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,974

Copied from: Help In SCript | SCN

Plagiarism is not tolerated in the forums. Any further instances of plagiarism will be reported to the TPTB and may lead to deletion of your user!

Read only

0 Likes
2,974

Hi Suhas,

I was giving reference to an example. If i had simply put that link, then that's also a violation or may lead to post deletion. What to do in that case?

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,974

Pranay Patel wrote:

I was giving reference to an example. If i had simply put that link, then that's also a violation or may lead to post deletion. What to do in that case?

That means the OP could have also found it if he had searched => you wanted to spoonfeed the OP, which btw is also an RoE violation    

Read only

Former Member
0 Likes
2,974

I set a break point on my printing program, inside the form read_zpm001 and it's not stoping there, which means I'm doing something wrong on the SAPscript:

/: PERFORM READ_ZPM001 IN PROGRAM ZRIPRJT00 CHANGING &OK&.

/: ENDPERFORM.

Any ideas?

Thank you all

Read only

0 Likes
2,974

Hi

USING and CHANGING parameters has to be indicated in an own command line


/: PERFORM READ_ZPM001 IN PROGRAM ZRIPRJT00 CHANGING &OK&.

/: PERFORM READ_ZPM001 IN PROGRAM ZRIPRJT00

/: CHANGING &OK&.

/: ENDPERFORM.

Max