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

SAP SCRIPT

Former Member
0 Likes
968

HOW TO ALIGN FIELD VALUES INTO CORRESPONDING FIELD NAME IN SAP SCRIPT.

7 REPLIES 7
Read only

Former Member
0 Likes
925

Hi,

Your question is not very clear...

if your question is how to assign the values of program variables to SAP Script Variables then read further

All the variables of the program (Along with the values at the time of the call of the SAP Script) are automatically available in the SAP Script

Typically one should use the same names as in the program.

If you still want to use different names you can try to do this the SAP Script

/: PERFORM (some form name) in Program (Z Program name)

USING program variable 1

program variable 2

program variable 3

CHANGING

SAP Script Variable1

SAP Script Variable2

SAP Script Variable3

/: END PERFORM

in then Z program form routine do the assignment

SAP Script Variable1 = program variable 1.

Its absoloutely a waste of time following this approach

its easier & better to simply use the program variables directly.

Regards,

Gaurav

Read only

0 Likes
925

: PERFORM SUM IN PROGRAM ZPROGRAM

/: USING &VAR1&

/: USING &VAR2&

/: CHANGING &RESULT&

/: ENDPERFORM

In the program(ZPROGRAM), we need to write the form ....

FORM SUM TABLES INTAB STRUCTURE ITCSY

OUTTAB STRUCTURE ITCSY.

data: field1 type i,

field2 type i,

result type i.

TO read the values from the ITAB you have to use this logic.

READ TABLE INTAB WITH KEY NAME = 'VAR1'.

IF SY-SUBRC = 0.

FIELD1 = INTAB-VALUE.

ENDIF.

READ TABLE INTAB WITH KEY NAME = 'VAR2'.

IF SY-SUBRC = 0.

FIELD2 = ITAB-VALUE.

ENDIF.

RESULT = V_FIELD1 + V_FIELD2.

READ TABLE OUTTAB INDEX 1.

IF SY-SUBRC = 0.

OTAB-VALUE = RESULT.

MODIFY OUTTAB INDEX 1 .

ENDIF.

ENDFORM.

BUT THIS IS NOT WORKING.PLS HELP....

Read only

Former Member
0 Likes
925

Hi,

we use the same variable in script as we declare in the program

say if we declare a variable v_num1 in program we will use &v_num1& to display this value.

if we want to use some other variable name we use 'DEFINE'

/: DEFINE v_num2 = &v_num1&.

Regards,

Vidya.

Read only

Former Member
0 Likes
925

Hi Dhamodharan,

As ABAPers we need not bother about mapping values from print program to script, we just need to ensure we use same variable name in both print program and script and populate the variable in the print program. Mapping the value to script is taken care of by SAP.

<u><b>Print program:</b></u>

DATA gv_count TYPE i.

gv_count = 5.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ELEM'

WINDOW = 'MAIN'

  • FUNCTION =

  • TYPE = .

<u><b>SAP Script.</b></u>/E elem

  • &gv_count&

Award points if useful.

Read only

Former Member
0 Likes
925

Hi Dhamodharan,

Kindly close the thread If Your question has been answered.

Also Kindly reward points to all helpful answers.

Regards,

Gaurav

Read only

Former Member
0 Likes
925

Hi dhamodharan,

U can use driver program variables directly in sapscript between &&.

or if u want another method means use below one.

CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'
               EXPORTING
                    name  = '&ATWRT&'  
                    value = v_atwrt.

Reward if helpful.

Thanks,

Suma.

Read only

Former Member
0 Likes
925

Hi Dhamodharan,

To align filed values in cor. filed names (that are in header) use tabs in paragraph format. u can give 20 tabs in CM, MM, CH.

Hope it will work fine.

Regards

Krishnendu