‎2014 Aug 21 5:08 PM
Hello Gurus!
i'm changing a sapscript with this structure
into this
Because before i got 2 fixed pages at the end (gen_cond + GEN_CON1, each one with a text include) but now the number of text includes to be printed are changed and they are not the same for each document
i got the famigerate message TD405
My code in printing is
DO nb_max TIMES.
nb_page = nb_page + 1.
IF nb_page = '01'."1st condtion page
CLEAR ztxt_gpc.
CONCATENATE ztext nb_page INTO ztxt_gpc.
CONDENSE ztxt_gpc.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'NEW-PAGE GEN_COND'
EXCEPTIONS
unopened = 1
unstarted = 2
OTHERS = 3.
ELSE. "other condition pages
CLEAR ztxt_gpc2.
CONCATENATE ztext nb_page INTO ztxt_gpc2.
CONDENSE ztxt_gpc2.
ENDIF.
ENDDO.Basically, 1st text, i call the new page, then i fill the text variables.
Any hints? To be honest, are ages i do not touch a sapscrit so i'm getting confused!
‎2014 Aug 22 3:17 PM
1- In sapscript For GEN_COND page
In the MAIN you need to declare an element
| /E | CONDITION | |
| /: | INCLUDE &ZTXT_GPC& OBJECT TEXT ID ST LANGUAGE &NAST-SPRAS& |
And in your Code
IF ztxt_gpc2 IS INITIAL AND ztxt_gpc IS NOT INITIAL.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'NEW-PAGE GEN_COND'
EXCEPTIONS
unopened = 1
unstarted = 2
OTHERS = 3.
ELSEIF ztxt_gpc IS NOT INITIAL AND ztxt_gpc2 IS NOT INITIAL.
nb_page = 0.
DO nb_max TIMES.
nb_page = nb_page + 1.
concatenate ztext nb_page into ztxt_gpc.
condense ztxt_gpc.
if nb_page = '01'. --> For the first page we trigger the new page and print the first page else
we got an empty page
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'NEW-PAGE GEN_COND'
EXCEPTIONS
unopened = 1
unstarted = 2
OTHERS = 3.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CONDITION'
WINDOW = 'MAIN'.
else.
CALL FUNCTION 'CONTROL_FORM' --> we call new-window command to go to the next Main
EXPORTING
command = 'NEW-WINDOW'
EXCEPTIONS
unopened = 1
unstarted = 2
OTHERS = 3.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CONDITION'
WINDOW = 'MAIN'.
endif.
ENDDO.
ENDIF.
‎2014 Aug 22 3:17 PM
1- In sapscript For GEN_COND page
In the MAIN you need to declare an element
| /E | CONDITION | |
| /: | INCLUDE &ZTXT_GPC& OBJECT TEXT ID ST LANGUAGE &NAST-SPRAS& |
And in your Code
IF ztxt_gpc2 IS INITIAL AND ztxt_gpc IS NOT INITIAL.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'NEW-PAGE GEN_COND'
EXCEPTIONS
unopened = 1
unstarted = 2
OTHERS = 3.
ELSEIF ztxt_gpc IS NOT INITIAL AND ztxt_gpc2 IS NOT INITIAL.
nb_page = 0.
DO nb_max TIMES.
nb_page = nb_page + 1.
concatenate ztext nb_page into ztxt_gpc.
condense ztxt_gpc.
if nb_page = '01'. --> For the first page we trigger the new page and print the first page else
we got an empty page
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'NEW-PAGE GEN_COND'
EXCEPTIONS
unopened = 1
unstarted = 2
OTHERS = 3.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CONDITION'
WINDOW = 'MAIN'.
else.
CALL FUNCTION 'CONTROL_FORM' --> we call new-window command to go to the next Main
EXPORTING
command = 'NEW-WINDOW'
EXCEPTIONS
unopened = 1
unstarted = 2
OTHERS = 3.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CONDITION'
WINDOW = 'MAIN'.
endif.
ENDDO.
ENDIF.
‎2014 Aug 22 3:23 PM