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

Help SAPScript and perform

Former Member
0 Likes
472

hi all,

i need to put a perform in a sapscript to obtein a theoric quantity and real quantity but i don't know how to implement it. can any body help me?

only i need an example of using a perform in a sapscript

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
419

Hi,

IN SCRIPT:

/: PERFORM GET_BARCODE6 IN PROGRAM ZVXR0076

/* USING &BARCV&

/: USING &BARC6&

/: CHANGING &BARCODE&

/: ENDPERFORM

IN PROGRAM ZVXR0076

FORM get_barcode TABLES sap_data STRUCTURE itcsy

abap_data STRUCTURE itcsy.

DATA : barcv LIKE karte-barcv,

barcode(11).

READ TABLE sap_data WITH KEY name = 'BARCV'.

IF sy-subrc EQ 0.

MOVE sap_data-value TO barcv.

ENDIF.

WRITE barcv TO barcode NO-ZERO.

CONDENSE barcode NO-GAPS.

READ TABLE abap_data WITH KEY name = 'BARCODE'.

IF sy-subrc EQ 0.

abap_data-value = barcode.

MODIFY abap_data INDEX sy-tabix.

ENDIF.

ENDFORM. "GET_BARCODE

check this link

http://www.sapdevelopment.co.uk/sapscript/sapscript_executeabap.htm

<i><b>

another example.</b></i>

in the script,

/: 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.

Regards,

Anver

2 REPLIES 2
Read only

anversha_s
Active Contributor
0 Likes
420

Hi,

IN SCRIPT:

/: PERFORM GET_BARCODE6 IN PROGRAM ZVXR0076

/* USING &BARCV&

/: USING &BARC6&

/: CHANGING &BARCODE&

/: ENDPERFORM

IN PROGRAM ZVXR0076

FORM get_barcode TABLES sap_data STRUCTURE itcsy

abap_data STRUCTURE itcsy.

DATA : barcv LIKE karte-barcv,

barcode(11).

READ TABLE sap_data WITH KEY name = 'BARCV'.

IF sy-subrc EQ 0.

MOVE sap_data-value TO barcv.

ENDIF.

WRITE barcv TO barcode NO-ZERO.

CONDENSE barcode NO-GAPS.

READ TABLE abap_data WITH KEY name = 'BARCODE'.

IF sy-subrc EQ 0.

abap_data-value = barcode.

MODIFY abap_data INDEX sy-tabix.

ENDIF.

ENDFORM. "GET_BARCODE

check this link

http://www.sapdevelopment.co.uk/sapscript/sapscript_executeabap.htm

<i><b>

another example.</b></i>

in the script,

/: 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.

Regards,

Anver

Read only

Clemenss
Active Contributor
0 Likes
419

Amversha,

the example given sould help you.

Just note that all parameters with SAPSCRIPT Performs are pure text, So if you want to use the CHANGING paremeters for output, you better use a WRITE TO .. statement in the form to have the output formatted adequate.

Regards

Clemens