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

Typical problem in sapscript

Former Member
0 Likes
641

Hi All,

In Sapscript , i am facing very typical problem. The summary of the problem is below.

In my final Internal table it_excdtl there is 4 entries . I am doing some calculation and Writing the contents through Write_form,

Only 1 set of value is coming in the Print out instead of 4 .

Can any one give me the tips :

Thanks in advance :

******************************

Sample code is attached :

CLEAR WA_EXCDTL .

Loop at it_excdtl INTO WA_EXCDTL.

IF WA_excdtl-menge NE 0.

wa_excdtl_amt_unit = ( WA_excdtl-exbed / WA_excdtl-menge ).

WA_EXCDTL_ED_UNIT = ( WA_excdtl-ecs / WA_excdtl-menge ).

WA_EXCDTL_CVD_UNIT = ( WA_excdtl-exaed / WA_excdtl-menge ).

ENDIF.

PERFORM write_form2.

FORM write_form2 .

  • LOOP AT tj_1irg23d.

*Loop at fp_out_tab.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'EMAIN2'

function = 'APPEND'

  • function = 'SET'

type = 'BODY'

window = 'MAIN2'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

OTHERS = 9

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • ENDLOOP.

ENDFORM. " WRITE_FORM2

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
608

Hi,

Try these changes and check


CLEAR WA_EXCDTL .

Loop at it_excdtl INTO WA_EXCDTL.
IF WA_excdtl-menge NE 0.
wa_excdtl_amt_unit = ( WA_excdtl-exbed / WA_excdtl-menge ).

WA_EXCDTL_ED_UNIT = ( WA_excdtl-ecs / WA_excdtl-menge ).

WA_EXCDTL_CVD_UNIT = ( WA_excdtl-exaed / WA_excdtl-menge ).

modify it_excdtl from wa_excdtl.
ENDIF.

PERFORM write_form2.

FORM write_form2 .

loop at it_excdtl.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'EMAIN2'
function = 'APPEND'
* function = 'SET'

type = 'BODY'
window = 'MAIN2'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
OTHERS = 9
.
IF sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.

ENDFORM. " WRITE_FORM2

Regards,

Vikranth

5 REPLIES 5
Read only

Former Member
0 Likes
608

Hey Kiro

Please check the loop

Loop at it_excdtl INTO WA_EXCDTL and the form write form is not in the loop so might be the problem is occuring in print since u r populating th e data for four entries ur not writing it for 4 .

Regards

Swapnil

Read only

Former Member
0 Likes
608

Hi,

-> Please write your WRITE_FORM inside a LOOP at gt_itab...ENDLOOP when you have multiple records populated in the internal table. I see that you have commented the LOOP...ENDLOOP...

-> If you think you have added it and it doesnt work yet, then check the size of the window in your SAP script. The size could have been small such that it can hold just one record.

-> Debug to find if your internal table is populated with multiple records

Read only

Former Member
0 Likes
609

Hi,

Try these changes and check


CLEAR WA_EXCDTL .

Loop at it_excdtl INTO WA_EXCDTL.
IF WA_excdtl-menge NE 0.
wa_excdtl_amt_unit = ( WA_excdtl-exbed / WA_excdtl-menge ).

WA_EXCDTL_ED_UNIT = ( WA_excdtl-ecs / WA_excdtl-menge ).

WA_EXCDTL_CVD_UNIT = ( WA_excdtl-exaed / WA_excdtl-menge ).

modify it_excdtl from wa_excdtl.
ENDIF.

PERFORM write_form2.

FORM write_form2 .

loop at it_excdtl.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'EMAIN2'
function = 'APPEND'
* function = 'SET'

type = 'BODY'
window = 'MAIN2'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
OTHERS = 9
.
IF sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.

ENDFORM. " WRITE_FORM2

Regards,

Vikranth

Read only

0 Likes
608

Hi All,

In Sap Script i have to print diffrent Text depanding upon the diffrent Supplying plant .

How to do this in Sap script . I have to write this details to the footer window of my Form .

Where Supplying plants details are maintained in Sapscript.

Thanks in advance .

Read only

venkat_o
Active Contributor
0 Likes
608

Hi, <li>Keep your PERFORM write_form2. subroutine call inside * LOOP - ENDLOOP.* Thanks Venkat.O