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

scripts

Former Member
0 Likes
888

Hi All,

I am having 3 windows in a page namely inform , address , main and created 3 diff itabs respectively.

Now how do i need to call the diff windows.

I mean will it work like

loop at t_inform.

call fn write_form.

endloop.

loop at t_address.

call fn write_form.

endloop.

loop at t_main.

call fn write_form.

endloop.

call fn close_form.

or else do i need to spacify start_form also.

Pls suggest.

Regards,

Nasru

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
844

Hi,

Since you are using 3 different internal tables for 3 windows data no need to call Start_form and End_form.

You are writing correctly only.

Actually with in the loop of same internal table when you are writing the data into different windows we use the Start_form and End_form. And also when you use different text_elements we use them.

loop at Itab.

at new kunnr.

perform start_form.

perform write_form using 'WINDOW1' 'TEXT1'.

perform End_form.

endat.

perform write_form using 'WINDOW2' 'TEXT2'

endloop.

In your case what you are writing is right.

reward if sueful

regards

Anji

7 REPLIES 7
Read only

Former Member
0 Likes
844

hi,

You need to call <b>OPEN_FORM</b>.

After that <b>write_form</b> and tehn <b>close_form</b>.

There is no need of start_form again.

Regarsd

Sailaja.

Read only

Former Member
0 Likes
844

hi,

do like this

<b> open_form.

start_form. *for 1st window

write_form.

end_form.

start_form. * for 2nd window

write_form.

end_form.

start_form. *for 3rd window

write_form.

end_form.

close_form.</b>

reward points if this helps u

ravi

Read only

Former Member
0 Likes
844

Nasru I think u can loop the variable in MAIN Window only for others u have to pass the values to print.

Read only

0 Likes
844

Hi ,

Can u b clear

Regards,

Nasru

Read only

Former Member
0 Likes
845

Hi,

Since you are using 3 different internal tables for 3 windows data no need to call Start_form and End_form.

You are writing correctly only.

Actually with in the loop of same internal table when you are writing the data into different windows we use the Start_form and End_form. And also when you use different text_elements we use them.

loop at Itab.

at new kunnr.

perform start_form.

perform write_form using 'WINDOW1' 'TEXT1'.

perform End_form.

endat.

perform write_form using 'WINDOW2' 'TEXT2'

endloop.

In your case what you are writing is right.

reward if sueful

regards

Anji

Read only

0 Likes
844

Hi Anji,

Thank u.

Suppose that i have mixed up all the three itab then can i call three diff wind

within a single loop at itab.

ex:

Loop at itab.

call fn write_form.

window = inform.

end fn.

call fn write_form.

window = main.

end fn.

call fn write_form.

window = address.

end fn.

endloop.

Pls clarify.

Regards,

Nasru

Read only

Former Member
0 Likes
844

Hai Nasru,

Within a single open_form and close form you can write as many write_forms as needed with text elements if needed that you are doing now.It is acceptable.

<b>If your print should come within a single spool request,then enclose them within Start_form and end_form.</b>

Hope you got it.

See the Sample code or use it:

"----


*" Data declarations...................................................

"----


  • Work variables *

"----


"----


DATA:

W_INDEX1 TYPE I, " Multi Address

W_INDEX TYPE C, " Vendar

W_NETPR TYPE EKPO-NETPR, " Net Prize

W_EBELN TYPE EKPO-EBELN, " Purchasing Document Number

W_EMLIF TYPE EKPO-EMLIF, " Vendor to be supplied

W_PAGENO TYPE I, " Current page number

W_N_PNO TYPE I, " Next Page number

W_FLAG TYPE C VALUE '0', " For last page

W_LINES TYPE I. " No.of records in T_EKPO Table

*"Table declarations...................................................

TABLES:

EKPO, " Purchasing Document Item

EKKO, " Purchasing Document Header

ADRC. " Address table

*"Selection screen elements............................................

SELECT-OPTIONS:

S_PD_NUM FOR EKPO-EBELN. " Purchasing Document Number

DATA:

BEGIN OF FS_EKPO,

EBELN TYPE EKPO-EBELN, " Purchasing Document Number

EBELP TYPE EKPO-EBELP, " Item No. of Purchasing Document

TXZ01 TYPE EKPO-TXZ01, " Material description

WERKS TYPE EKPO-WERKS, " Plant

LGORT TYPE EKPO-LGORT, " Storage Location

NETPR TYPE EKPO-NETPR, " Net Prize

MATNR TYPE EKPO-MATNR, " Material number

AEDAT TYPE EKPO-AEDAT, " Purchasing doc item change date

EMLIF TYPE EKPO-EMLIF, " Vendor to be supplied

PEINH TYPE EKPO-PEINH, " Price Unit

END OF FS_EKPO.

DATA:

T_EKKO TYPE TABLE OF EKKO,

FS_EKKO LIKE LINE OF T_EKKO.

DATA:

T_EKPO LIKE STANDARD TABLE OF FS_EKPO.

SELECT EBELN " Purchasing Document Number

EBELP " Item No. of Purchasing Document

TXZ01 " Material description

WERKS " Plant

LGORT " Storage Location

NETPR " Net Prize

MATNR " Material number

AEDAT " Purchasing doc item change date

EMLIF " Vendor to be supplied

PEINH " Price Unit

INTO TABLE T_EKPO

FROM EKPO

WHERE EBELN IN S_PD_NUM.

IF SY-SUBRC NE 0.

MESSAGE 'No Records found in EKPO Table' TYPE 'I'.

STOP.

ENDIF.

*LOOP AT T_EKPO INTO FS_EKPO.

  • WRITE:/

  • FS_EKPO-MATNR.

*ENDLOOP.

READ TABLE T_EKPO INTO FS_EKPO INDEX 1.

SELECT SINGLE *

FROM EKPO

WHERE EBELN EQ S_PD_NUM

AND LGORT NE FS_EKPO-LGORT.

W_INDEX = W_INDEX1.

DESCRIBE TABLE T_EKPO LINES W_LINES.

CALL FUNCTION 'OPEN_FORM'

  • EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

  • DEVICE = 'PRINTER'

  • DIALOG = 'X'

  • FORM = 'YH650_060202'

  • LANGUAGE = SY-LANGU

  • OPTIONS =

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJECT =

  • RAW_DATA_INTERFACE = '*'

  • SPONUMIV =

  • IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

  • RESULT =

EXCEPTIONS

CANCELED = 1

DEVICE = 2

FORM = 3

OPTIONS = 4

UNCLOSED = 5

MAIL_OPTIONS = 6

ARCHIVE_ERROR = 7

INVALID_FAX_NUMBER = 8

MORE_PARAMS_NEEDED_IN_BATCH = 9

SPOOL_ERROR = 10

CODEPAGE = 11

OTHERS = 12

.

IF SY-SUBRC <> 0.

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

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

ENDIF. " IF SY-SUBRC <> 0.

LOOP AT T_EKPO INTO FS_EKPO.

W_EMLIF = FS_EKPO-EMLIF.

W_EBELN = FS_EKPO-EBELN.

W_NETPR = FS_EKPO-NETPR.

SELECT SINGLE *

INTO FS_EKKO

FROM EKKO

WHERE EBELN EQ FS_EKPO-EBELN.

*READ TABLE T_EKKO INTO FS_EKKO INDEX 1.

IF SY-TABIX GE W_LINES.

W_FLAG = '1'.

ENDIF.

AT NEW EBELN.

ADD 1 TO W_PAGENO.

W_N_PNO = W_PAGENO + 1.

CALL FUNCTION 'START_FORM'

EXPORTING

  • ARCHIVE_INDEX =

FORM = 'YH650_060205'

  • LANGUAGE = ' '

  • STARTPAGE = ' '

  • PROGRAM = ' '

  • MAIL_APPL_OBJECT =

  • IMPORTING

  • LANGUAGE =

EXCEPTIONS

FORM = 1

FORMAT = 2

UNENDED = 3

UNOPENED = 4

UNUSED = 5

SPOOL_ERROR = 6

CODEPAGE = 7

OTHERS = 8

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ENDAT. " AT NEW EBELN.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'DATA'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

  • WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

SPOOL_ERROR = 8

CODEPAGE = 9

OTHERS = 10

.

IF SY-SUBRC <> 0.

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

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

ENDIF. " IF SY-SUBRC <> 0.

IF W_INDEX GT 1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'MAINADDRESS'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

  • WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

SPOOL_ERROR = 8

CODEPAGE = 9

OTHERS = 10

.

IF SY-SUBRC <> 0.

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

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

ENDIF. " IF SY-SUBRC <> 0.

ENDIF. " IF W_INDEX GT 1.

AT END OF EBELN.

CALL FUNCTION 'WRITE_FORM'

  • EXPORTING

  • ELEMENT = ' '

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

  • WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

SPOOL_ERROR = 8

CODEPAGE = 9

OTHERS = 10

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

CALL FUNCTION 'END_FORM'

  • IMPORTING

  • RESULT =

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

SPOOL_ERROR = 3

CODEPAGE = 4

OTHERS = 5

.

IF SY-SUBRC <> 0.

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

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

ENDIF. " IF SY-SUBRC <> 0.

ENDAT. " AT END OF EBELN.

*ADD 1 TO W_PAGENO.

ENDLOOP. " LOOP AT T_EKPO INTO FS_EKPO.

CALL FUNCTION 'CLOSE_FORM'

  • IMPORTING

  • RESULT =

  • RDI_RESULT =

  • TABLES

  • OTFDATA =

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

SEND_ERROR = 3

SPOOL_ERROR = 4

CODEPAGE = 5

OTHERS = 6

.

IF SY-SUBRC <> 0.

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

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

ENDIF. " IF SY-SUBRC <> 0.

&----


*& Form SHIP_ADDRESS

&----


  • This subroutine takes Plant and Storage Location as input parameters*

  • and then it gives the address number for the corresponding plant

  • Storage Location *

----


  • -->IN_PAR text

  • -->OUT_PAR text

----


FORM SHIP_ADDRESS TABLES IN_PAR STRUCTURE ITCSY

OUT_PAR STRUCTURE ITCSY.

DATA:

LW_ADRNR TYPE TWLAD-ADRNR,

LW_INDEX TYPE I,

LW_LINE LIKE LINE OF IN_PAR,

LW_LINES,

LW_LINES1 TYPE I.

DESCRIBE TABLE IN_PAR LINES LW_LINES.

DO LW_LINES TIMES.

ADD 1 TO LW_LINES1.

READ TABLE IN_PAR INTO LW_LINE INDEX LW_LINES1.

IF LW_LINES1 EQ 1.

FS_EKPO-WERKS = LW_LINE-VALUE.

ELSE.

FS_EKPO-LGORT = LW_LINE-VALUE.

ENDIF. " IF LW_LINES1 EQ 1.

ENDDO. " DO LW_LINES TIMES.

SELECT ADRNR " Address Number

INTO LW_ADRNR

FROM TWLAD

WHERE WERKS = FS_EKPO-WERKS

AND LGORT = FS_EKPO-LGORT. " SELECT ADRNR...

ADD 1 TO LW_INDEX.

OUT_PAR-NAME = 'LW_ADRNR'.

OUT_PAR-VALUE = LW_ADRNR.

MODIFY OUT_PAR INDEX LW_INDEX TRANSPORTING VALUE.

ENDSELECT.

IF SY-SUBRC NE 0.

W_INDEX = 2.

ENDIF. " IF SY-SUBRC NE 0.

ENDFORM. " SHIP_ADDRESS

<b>Reward points if it helps you.</b>

Regds,

Rama chary.Pammi