‎2007 Apr 09 6:17 AM
Hi friends,
In sales order there are number of brokers(lifnr) are involved in items selling
i want send acknowledgement each broker(lifnr) with respective items.
i have all the items corresponding to sales order(vbeln) in one internal table.
only items are different in broker acknowledgement form.
<b>how can i trigger form for each broker(lifnr)</b> and all other details same in each form.
please help. reward point sure.
Regards
Deepa
‎2007 Apr 09 6:27 AM
Hi..,
<b>This is a sample program which triggers a new form for each new value of EBELN...
Check the way in which the START_FORM and END_FORM are used in this program , then u can easily solve your problem....<b></b></b>
tables:
ekpo.
*"Selection screen elements............................................
select-options:
s_ebeln for ekpo-ebeln. " Puchasing document numbers.
"----
Type declaration of the structure to hold adress numbers *
"----
types:
begin of type_s_ekpo,
ebeln type ekpo-ebeln, " Purchase order number
ebelp type ekpo-ebelp, " Item number
txz01 type ekpo-txz01, " Material description
matnr type ekpo-matnr, " Material number
werks type ekpo-werks, " Plant
lgort type ekpo-lgort, " Storage location
netpr type ekpo-netpr, " Net price
waers type ekko-waers, " Price unit
lifnr type ekko-lifnr, " Vendor number
aedat type ekpo-aedat, " Entry Date
end of type_s_ekpo.
types:
begin of type_s_address,
werks type ekpo-werks,
lgort type ekpo-lgort,
end of type_s_address.
"----
Declaration of internal table and work area to store address numbers*
"----
data :
t_ekpo type standard table
of type_s_ekpo
initial size 0,
t_address type standard table
of type_s_address
initial size 0.
data wa_ekpo type type_s_ekpo.
Data Declarations....................................................
data:
w_lines type i,
w_address type c,
w_adrnr type adrc-addrnumber,
w_flag type c,
w_ebeln type ekpo-ebeln,
w_waers type ekko-waers,
w_aedat type ekpo-aedat,
w_lifnr type ekko-lifnr,
w_werks type ekpo-werks,
w_lgort type ekpo-lgort,
w_page type i.
"----
AT SELECTION-SCREEN EVENT *
"----
at selection-screen.
perform validation.
"----
START OF SELECTION EVENT *
"----
start-of-selection.
perform operation.
&----
*& Form operation
&----
This subroutine opens a form and sends data to that and closes it*
----
There are no interface parameters for this subroutine *
----
form operation.
call function 'OPEN_FORM'
EXPORTING
FORM = ' '
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.
loop at t_ekpo into wa_ekpo.
w_ebeln = wa_ekpo-ebeln.
w_aedat = wa_ekpo-aedat.
w_waers = wa_ekpo-waers.
w_lifnr = wa_ekpo-lifnr.
w_werks = wa_ekpo-werks.
w_lgort = wa_ekpo-lgort.
at new ebeln.
select werks
lgort
from ekpo
into table t_address
for all entries in t_ekpo
where ebeln eq wa_ekpo-ebeln
and werks eq t_ekpo-werks
and lgort eq t_ekpo-lgort.
describe table t_address lines w_lines.
if w_lines eq 1.
w_address = '1'.
endif.
call function 'START_FORM'
EXPORTING
ARCHIVE_INDEX =
FORM = 'YH640_060205'
LANGUAGE = SY-LANGU
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.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'DATA'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
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 NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
at end of ebeln.
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.
clear : t_address,w_address, w_flag.
endat.
endloop.
call function 'CLOSE_FORM'
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.
endform. " Form operation.
&----
*& Form validation
&----
This subroutine validates the user input *
----
There are no interface parameters for this subroutine *
----
form validation.
select ekpo~ebeln
ebelp
txz01
matnr
werks
lgort
netpr
waers
lifnr
ekko~aedat
into table t_ekpo
from ekpo as ekpo inner join ekko as ekko
on ekpoebeln eq ekkoebeln
where ekpo~ebeln in s_ebeln.
if sy-subrc ne 0.
message e020(yh640).
endif.
endform. " Form validation
&----
*& Form address *
&----
form address tables in_storage structure itcsy
out_storage structure itcsy.
data :
lw_werks type ekpo-werks,
lw_lgort type ekpo-lgort.
read table in_storage with key name = 'W_WERKS'.
check sy-subrc eq 0.
lw_werks = in_storage-value.
read table in_storage with key name = 'W_LGORT'.
check sy-subrc eq 0.
lw_lgort = in_storage-value.
select adrnr
from twlad
into w_adrnr
where werks eq lw_werks
and lgort eq lw_lgort.
if sy-subrc eq 0.
w_flag = '1'.
read table out_storage with key name = 'W_ADRNR'.
out_storage-value = w_adrnr.
modify out_storage index sy-tabix.
endif.
endselect.
endform.
<b>
Hope this helps u,</b>
regards,
sai ramesh
‎2007 Apr 09 6:23 AM
Hi,
first desing your own script and custom driver program for this.
Create the form in SE71 with the data and fetch the data in the driver program from the related SO tables like VBAK,VBAP etc.
Call the form in the driver program OPEN_FORM.
put the all related data in one internal table ITAB , sort it by Broker(LIFNR) field
Loop at ITAB.
at new lifnr.
call function Start_form using window element.
endat.
call function write_form using window element.
endloop.
when you use Start_form and Write_form for each lifnr, data will be printed using the same form for different brokers.
reward points if useful
regards,
Anji
Message was edited by:
Anji Reddy Vangala
‎2007 Apr 09 6:27 AM
Hi..,
<b>This is a sample program which triggers a new form for each new value of EBELN...
Check the way in which the START_FORM and END_FORM are used in this program , then u can easily solve your problem....<b></b></b>
tables:
ekpo.
*"Selection screen elements............................................
select-options:
s_ebeln for ekpo-ebeln. " Puchasing document numbers.
"----
Type declaration of the structure to hold adress numbers *
"----
types:
begin of type_s_ekpo,
ebeln type ekpo-ebeln, " Purchase order number
ebelp type ekpo-ebelp, " Item number
txz01 type ekpo-txz01, " Material description
matnr type ekpo-matnr, " Material number
werks type ekpo-werks, " Plant
lgort type ekpo-lgort, " Storage location
netpr type ekpo-netpr, " Net price
waers type ekko-waers, " Price unit
lifnr type ekko-lifnr, " Vendor number
aedat type ekpo-aedat, " Entry Date
end of type_s_ekpo.
types:
begin of type_s_address,
werks type ekpo-werks,
lgort type ekpo-lgort,
end of type_s_address.
"----
Declaration of internal table and work area to store address numbers*
"----
data :
t_ekpo type standard table
of type_s_ekpo
initial size 0,
t_address type standard table
of type_s_address
initial size 0.
data wa_ekpo type type_s_ekpo.
Data Declarations....................................................
data:
w_lines type i,
w_address type c,
w_adrnr type adrc-addrnumber,
w_flag type c,
w_ebeln type ekpo-ebeln,
w_waers type ekko-waers,
w_aedat type ekpo-aedat,
w_lifnr type ekko-lifnr,
w_werks type ekpo-werks,
w_lgort type ekpo-lgort,
w_page type i.
"----
AT SELECTION-SCREEN EVENT *
"----
at selection-screen.
perform validation.
"----
START OF SELECTION EVENT *
"----
start-of-selection.
perform operation.
&----
*& Form operation
&----
This subroutine opens a form and sends data to that and closes it*
----
There are no interface parameters for this subroutine *
----
form operation.
call function 'OPEN_FORM'
EXPORTING
FORM = ' '
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.
loop at t_ekpo into wa_ekpo.
w_ebeln = wa_ekpo-ebeln.
w_aedat = wa_ekpo-aedat.
w_waers = wa_ekpo-waers.
w_lifnr = wa_ekpo-lifnr.
w_werks = wa_ekpo-werks.
w_lgort = wa_ekpo-lgort.
at new ebeln.
select werks
lgort
from ekpo
into table t_address
for all entries in t_ekpo
where ebeln eq wa_ekpo-ebeln
and werks eq t_ekpo-werks
and lgort eq t_ekpo-lgort.
describe table t_address lines w_lines.
if w_lines eq 1.
w_address = '1'.
endif.
call function 'START_FORM'
EXPORTING
ARCHIVE_INDEX =
FORM = 'YH640_060205'
LANGUAGE = SY-LANGU
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.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'DATA'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
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 NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
at end of ebeln.
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.
clear : t_address,w_address, w_flag.
endat.
endloop.
call function 'CLOSE_FORM'
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.
endform. " Form operation.
&----
*& Form validation
&----
This subroutine validates the user input *
----
There are no interface parameters for this subroutine *
----
form validation.
select ekpo~ebeln
ebelp
txz01
matnr
werks
lgort
netpr
waers
lifnr
ekko~aedat
into table t_ekpo
from ekpo as ekpo inner join ekko as ekko
on ekpoebeln eq ekkoebeln
where ekpo~ebeln in s_ebeln.
if sy-subrc ne 0.
message e020(yh640).
endif.
endform. " Form validation
&----
*& Form address *
&----
form address tables in_storage structure itcsy
out_storage structure itcsy.
data :
lw_werks type ekpo-werks,
lw_lgort type ekpo-lgort.
read table in_storage with key name = 'W_WERKS'.
check sy-subrc eq 0.
lw_werks = in_storage-value.
read table in_storage with key name = 'W_LGORT'.
check sy-subrc eq 0.
lw_lgort = in_storage-value.
select adrnr
from twlad
into w_adrnr
where werks eq lw_werks
and lgort eq lw_lgort.
if sy-subrc eq 0.
w_flag = '1'.
read table out_storage with key name = 'W_ADRNR'.
out_storage-value = w_adrnr.
modify out_storage index sy-tabix.
endif.
endselect.
endform.
<b>
Hope this helps u,</b>
regards,
sai ramesh