‎2007 Jun 15 9:25 PM
Hi All,
The requirement is:
When the report program is executed a screen should come with spool request no. and on clicking that another screen comes where we can see Print Preview or give the print program.(As while executing a standard driver program eg RFFOUS_C).
What I m getting after execution is Print Preview Optionand then Print preview.
Any demo programs or any solution will be highly obiliged.
Thanks
Vivek
‎2007 Jun 15 9:39 PM
see the program and i used print controls to form
<b>w_itcpo-tdcopies = '1'.
w_itcpo-tddest = 'LOCL'.
w_itcpo-tdprinter = 'NAME'.
w_itcpo-tddelete = 'X'.
w_itcpo-tdimmed = 'X'.
w_itcpo-tddataset = 'NEW'.
W_ITCPO-TDNOPRINT = 'X'.
w_itcpo-tdnewid = 'X'.
w_itcpo-tdpreview = 'X'.
w_itcpo-tdcovtitle = 'QA PLANNING LIST'.</b>
the above code should use in open_form FM
report zjpar_Lay no standard page heading
line-size 130 line-count 25 message-id zw.
&----
*& Development ID:PU_DD_313_LJP *
*& *
*& Report ZJPMRPU313 *
*& *
& This program outputs the Test Execution Plan details.The selection-
*& screen contains two radio buttons for Manufactured product and *
& Purchased product.Based on selection of any one of the radio button
*& it will send the details to printer. Before going to output it *
*& shows print preview option. This program send the data to printer. *
&----
*& Change Log: *
*& *
*& Init. Who Date Text *
*& V Seshu 09.06.2003 Initial version *
&----
Include program to declare all the global data.
*INCLUDE ZJPMITOP.
constants : c_plant like ekpo-werks value 'JP01', "Plant
c_pur_org like ekko-ekorg value 'JP30', "Puchasing
"Organization
c_days type i value 1, "
c_hdays type i value 2. "Holidays
"saturday and sunday
----
VARIBLES / INTERNAL TABLES
----
data : g_lead_time type i, "To store lead time
g_weeks type p, "
g_week type i,
g_days like scal-indicator,
g_days1 type i,
g_var1 type i,
g_form_name(20) type c,
g_sdate like sy-datum,
g_total_records type i,
g_type(4) TYPE c, " LIKE MARA-MTART.
g_text like t134t-mtbez,
g_tabix like sy-tabix.
----
DATABASE TABLES
----
tables : mara, "Material Master Data
t134, "Material Type
t134t, "Material Type Descriptions
t001w,
t024e,
marc, "Material Data for Plant
lfa1, "Vendor Master
ekko, "Purchasing Order Header data
ekpo. "Purchasing Order Item data
makt, "Material Descriptions
likp, "Delivery Document Header
lips, "Delivery Document Item
eket. "Scheduling Agreement Schedule Lines
ekes, "Vendor Confirmations
afko, "Order Header Data
afvv, "DB structure of the quantities/dates/values in
"the operation
afvu, "DB structure of the user fields of the
*Operation
z0cl_batglo .
data :w_itcpo like itcpo.
Internal Table to store purchasing product details
data : begin of t_output_pur occurs 0,
mtart like ekpo-mtart,
ebeln like eket-ebeln,
ebelp like eket-ebelp,
matnr like ekpo-matnr,
ematn like ekpo-ematn,
maktx like makt-maktx,
matkl like ekpo-matkl,
etens like ekes-etens,
charg like eket-charg,
licha like eket-licha,
meins like ekpo-meins,
menge(9) type p decimals 3, "LIKE EKET-MENGE,
eindt like eket-eindt,
sapsd like eket-eindt,
webaz like marc-webaz,
tetsd like eket-eindt, " TEST TERMINATION DATE
lifnr like ekko-lifnr,
LLIEF LIKE EKKO-LLIEF,
name1 like lfa1-name1,
mtbez like t134t-mtbez,
end of t_output_pur.
Internal Table to store Manufacturing product details
data : begin of t_output_mp occurs 0,
matkl like mara-matkl,
mtart like mara-mtart,
from_date like sy-datum,
to_date like sy-datum,
aufnr like afko-aufnr,
plnbez like afko-plnbez,
maktx like makt-maktx,
charg like afpo-charg,
gamng like afko-gamng,
gmein like afko-gmein,
ftrmi like afko-ftrmi,
ssedd like afvv-ssedd, "SAMPLE PROCUREMENT DATE
spsdd like afvv-ssedd,
scted like afvv-ssedd,
webaz like marc-webaz,
gltri like afko-gltri,
name1 like lfa1-name1,
aufpl like afko-aufpl,
printing1 like z0cl_batglo-printing1,
end of t_output_mp.
Internal table to store Order header data from AFKO & AFPO tables.
data : begin of t_afko occurs 0,
aufnr like afko-aufnr,
gltri like afko-gltri,
plnbez like afko-plnbez,
charg like afpo-charg,
gamng like afko-gamng,
gmein like afko-gmein,
ftrms like afko-ftrms,
ftrmi like afko-ftrmi,
aufpl like afko-aufpl,
maktx like makt-maktx,
end of t_afko.
Internal table to hold DB structure of the user fields of the
operation
data : begin of t_afvu occurs 0,
aufpl like afvu-aufpl,
aplzl like afvu-aplzl,
usr11 like afvu-usr11,
end of t_afvu.
Internal table to hold DB structure of the quantities/dates/values in
the operation
data : begin of t_afvv occurs 0,
aufpl like afvv-aufpl,
aplzl like afvv-aplzl,
ssedd like afvv-ssedd,
end of t_afvv.
Internal table to hold Vendor confirmation details from EKES table.
data : begin of t_ekes occurs 0,
ebeln like ekes-ebeln,
ebelp like ekes-ebelp,
eindt like ekes-eindt,
etens like ekes-etens,
menge like ekes-menge,
ematn like ekes-ematn,
charg like ekes-charg,
end of t_ekes.
Internal table to store purchased order details from EKKO & EKPO.
data : begin of t_eket occurs 0,
ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
matnr like ekpo-matnr,
ematn like ekpo-ematn,
mtart like ekpo-mtart,
matkl like ekpo-matkl,
meins like ekpo-meins,
lifnr like ekko-lifnr,
ekorg like ekko-ekorg,
werks like ekpo-werks,
llief like ekko-llief,
eindt like eket-eindt,
menge like eket-menge,
end of t_eket.
Internal table to hold Delivery order data
particularly lot information
data : begin of t_lips occurs 0,
vgbel like lips-vgbel,
vgpos like lips-vgpos,
lfimg like lips-lfimg,
vbeln like lips-vbeln,
matnr like lips-matnr,
lifnr like likp-lifnr,
lfdat like likp-lfdat,
charg like lips-charg,
lichn like lips-lichn,
mbdat like lips-mbdat,
end of t_lips.
data: begin of t_t024e occurs 0,
ekorg like t024e-ekorg,
end of t_t024e.
Internal table to hold material names
data : begin of t_makt occurs 0,
matnr like makt-matnr,
maktx like makt-maktx,
spras like makt-spras,
end of t_makt.
Internal table to hold Vendor names
data: begin of t_lfa1 occurs 0,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
end of t_lfa1.
Internal table to hold Lead times for materials
data : begin of t_marc occurs 0,
matnr like marc-matnr,
webaz like marc-webaz,
end of t_marc.
Internal table to hold Batch master details
data : begin of t_z0cl_batglo occurs 0,
matnr like z0cl_batglo-matnr,
charg like z0cl_batglo-charg,
printing1 like z0cl_batglo-printing1,
PRODSITE LIKE Z0CL_BATGLO-PRODSITE,
end of t_z0cl_batglo.
data :begin of t_t134t occurs 0,
mtart like t134t-mtart,
mtbez like t134t-mtbez,
end of t_t134t.
data :begin of t_mara occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
end of t_mara.
data : begin of t_t001w occurs 0,
werks like t001w-werks,
end of t_t001w.
data : begin of t_field_names occurs 0,
fieldname(100) type c,
end of t_field_names.
data: g_table like table of t_output_pur .
----
SELECT-OPTIONS/ PARAMETERS
*
----
selection-screen begin of block qa_planning_list with frame title
text-100.
select-options : s_mtart for mara-mtart no intervals obligatory,
s_period for sy-datum default sy-datum,
s_plant for ekpo-werks default c_plant no intervals,
s_ekorg for ekko-ekorg default c_pur_org no intervals.
selection-screen end of block qa_planning_list.
selection-screen begin of block product_selection with frame title
text-101.
parameters: rb_r1 radiobutton group g1, " Purchased Product
rb_r2 radiobutton group g1. " Manufactured Product
selection-screen end of block product_selection.
*PARAMETER : S_FILE LIKE RLGRAP-FILENAME.
**********************************************************************
*INITIALIZATION.
**********************************************************************
initialization.
**********************************************************************
AT SELECTION-SCREEN : SELECTION SCREEN PRE PROCCESSING.
**********************************************************************
at selection-screen on s_mtart .
perform f_check_mtart.
at selection-screen on s_plant .
perform f_check_plant.
at selection-screen on s_ekorg .
perform f_check_purchase_organization.
**********************************************************************
*START-OF-SELECTION.
**********************************************************************
----
*** MAIN PROCESSING *** *
----
start-of-selection.
set pf-status 'TEST'.
if not rb_r1 is initial.
To get Schedule line data for given selection.
perform f_get_data.
Updating the Schedule line Date and Quantity with Vendor confirmation
data.
perform f_process_data.
else.
To get Manufacturing Product Details
perform f_process_mp.
perform f_order_data.
endif.
************************************************************************
*END-OF-SELECTION.
************************************************************************
end-of-selection.
if not rb_r1 is initial.
g_form_name = 'ZJPMPU313_PO'.
if not t_output_pur[] is initial.
perform f_open_form.
perform f_format_data.
else.
message s016(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'(t01).
exit.
endif.
else.
g_form_name = 'ZJPMPU313_MP'.
perform f_format_mp_data.
if not t_output_mp[] is initial.
perform f_open_form.
perform f_format_mp_data.
perform f_write_form_mp.
else.
message s017(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
exit.
endif.
endif.
*Close Sap script form
perform f_close_form.
*To release all Internal tables memory space
perform f_free_memory.
&----
*& Form F_UPDATE_QTY
&----
Update Quantity, Delivery Date from EKES table to EKET table.
Then move EKET data to Output table.
----
form f_update_qty.
read table t_lips with key vgbel = t_ekes-ebeln
vgpos = t_ekes-ebelp
charg = t_ekes-charg binary search.
if sy-subrc eq 0.
t_eket-menge = t_ekes-menge.
t_eket-eindt = t_ekes-eindt.
MODIFY t_eket TRANSPORTING menge eindt.
move t_lips-charg to t_output_pur-charg.
move t_lips-lichn to t_output_pur-licha.
endif.
move t_eket-ebeln to t_output_pur-ebeln.
move t_eket-ebelp to t_output_pur-ebelp.
MOVE T_EKET-EMATN TO T_OUTPUT_PUR-EMATN.
move t_eket-matnr to t_output_pur-matnr.
move t_eket-meins to t_output_pur-meins.
move t_eket-mtart to t_output_pur-mtart.
move t_ekes-menge to t_output_pur-menge.
move t_ekes-eindt to t_output_pur-eindt.
move t_ekes-etens to t_output_pur-etens.
move t_eket-lifnr to t_output_pur-lifnr.
move t_eket-matkl to t_output_pur-matkl.
MOVE T_EKET-LLIEF TO T_OUTPUT_PUR-LLIEF.
read table t_makt with key matnr = t_eket-ematn binary search.
if sy-subrc eq 0.
t_output_pur-maktx = t_makt-maktx.
endif.
read table t_lfa1 with key lifnr = t_eket-llief binary search.
if sy-subrc eq 0.
move t_lfa1-name1 to t_output_pur-name1.
endif.
read table t_t134t with key mtart = t_eket-mtart.
if sy-subrc eq 0.
move t_t134t-mtbez to t_output_pur-mtbez.
endif.
perform f_spsdate.
*Calculating Test termination Schedule Date
perform f_test_term_sched_date using g_sdate. "T_OUTPUT_PUR-SAPSD.
append t_output_pur.
clear t_output_pur.
clear t_ekes.
clear t_lips.
endform. " F_UPDATE_QTY
&----
*& Form SPSDATE
&----
It calculates Sample Procurement Schedule Date.
Function module Date_Compute_Day return the day that falls in the *
week
----
form f_spsdate.
g_sdate = t_eket-eindt.
call function 'DATE_COMPUTE_DAY'
exporting
date = g_sdate
importing
day = g_days.
g_days2 = g_days.
if g_days gt 5.
g_sdate = g_sdate + c_days + c_hdays.
else.
g_sdate = g_sdate + c_days.
endif.
t_output_pur-sapsd = g_sdate.
endform. " SPSDATE
&----
*& Form PROCESS_MP
&----
This subroutine fetch all necessary data for Production Order
Details
----
form f_process_mp.
select a~aufnr
a~gltri
a~plnbez
b~charg
a~gamng
a~gmein
a~ftrms
a~ftrmi
a~aufpl
from afko as a inner join afpo as b
on aaufnr eq baufnr
into table t_afko
where a~gltri in s_period.
if not t_afko[] is initial.
select aufpl aplzl usr11 from afvu
into table t_afvu for all entries in t_afko
where aufpl = t_afko-aufpl
and usr11 eq 'X'.
else.
message s010(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
endif.
if not t_afvu[] is initial.
select aufpl aplzl ssedd from afvv
into table t_afvv
for all entries in t_afvu
where aufpl = t_afvu-aufpl
and aplzl = t_afvu-aplzl
and ssedd in s_period.
else.
message s010(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
endif.
if not t_afko[] is initial.
select matnr maktx from makt into table t_makt
for all entries in t_afko
where spras eq sy-langu
and matnr eq t_afko-plnbez.
select matnr charg printing1 from z0cl_batglo
into table t_z0cl_batglo
for all entries in t_afko
where matnr eq t_afko-plnbez
and charg eq t_afko-charg.
select matnr mtart from mara into table t_mara
for all entries in t_afko
where matnr eq t_afko-plnbez
and mtart in s_mtart.
else.
message s010(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
endif.
endform. " PROCESS_MP
&----
*& Form F_get_data
&----
This subroutine fetches all necessary data for Purchased Product
details from EKET and EKES tables and store into the internal tables
----
form f_get_data.
select a~ebeln
a~ebelp
a~matnr
a~ematn
a~mtart
a~matkl
a~meins
b~lifnr
b~ekorg
a~werks
b~llief
c~eindt
c~menge
into table t_eket
from ( ( ekpo as a inner join ekko as b
on aebeln eq bebeln )
inner join eket as c
on cebeln eq aebeln
and cebelp eq aebelp )
where a~mtart in s_mtart
and a~werks in s_plant
and b~ekorg in s_ekorg
and c~eindt in s_period.
if sy-subrc eq 0.
sort t_eket by ebeln ebelp.
delete adjacent duplicates from t_eket comparing ebeln ebelp.
select ebeln ebelp eindt etens menge ematn charg
into table t_ekes from ekes
for all entries in t_eket
where eindt in s_period
and ematn eq t_eket-matnr
and ebeln eq t_eket-ebeln
and ebelp eq t_eket-ebelp.
select matnr maktx from makt into table t_makt
for all entries in t_eket
where spras eq sy-langu
and matnr eq t_eket-matnr.
FILLING T_MARC TABLE
select matnr webaz from marc into table t_marc
for all entries in t_eket
where werks in s_plant
and matnr eq t_eket-matnr.
*VENDOR NAME
select lifnr name1 from lfa1 into table t_lfa1
for all entries in t_eket
where lifnr = t_eket-lifnr.
else.
message s010(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
MESSAGE S000 WITH 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
leave list-processing.
endif.
*FILLING THE INTERNAL TABLE T_LIPS.
select avgbel avgpos alfimg avbeln amatnr blifnr b~lfdat
acharg alichn a~mbdat into table t_lips
from lips as a inner join likp as b
on avbeln = bvbeln
where a~mbdat in s_period
and a~vbtyv eq 'V'.
endform. " F_get_data
&----
*& Form CHECK_MTART
&----
This subroutine validates material type which is given by User.
----
-->P_P_MTART text
----
form f_check_mtart.
select mtart mtbez from t134t into table t_t134t where spras eq sy-langu
.
loop at s_mtart.
read table t_t134t with key mtart = s_mtart-low.
if sy-subrc ne 0.
message e020(zw) with 'invalid Material Type'.
message e000 with 'invalid material type'(t01).
endif.
endloop.
endform. " CHECK_MTART
&----
*& Form F_TEST_TERM_SCHED_DATE
&----
This subroutine calculates Test Termination Schedule Date.
----
-->P_t_output_PUR_sapsd text
----
form f_test_term_sched_date using p_t_output_pur_sapsd.
if not rb_r1 is initial.
read table t_marc with key matnr = t_output_pur-ematn .
else.
read table t_marc with key matnr = t_output_mp-plnbez .
endif.
move t_marc-webaz to t_output_pur-webaz.
g_lead_time = t_marc-webaz.
g_weeks = ( trunc( g_lead_time / 5 ) ) * 7.
g_week = g_lead_time mod 5.
call function 'DATE_COMPUTE_DAY'
exporting
date = p_t_output_pur_sapsd
importing
day = g_days.
g_days1 = g_days.
g_var1 = g_days1 + g_week.
if g_var1 > 5 and g_week ne 0.
g_week = g_week + 2.
endif.
g_weeks = g_weeks + g_week.
if not rb_r1 is initial.
t_output_pur-tetsd = p_t_output_pur_sapsd + g_weeks.
else.
t_output_mp-scted = p_t_output_pur_sapsd + g_weeks.
endif.
clear g_sdate.
endform. " F_TEST_TERM_SCHED_DATE
&----
*& Form F_FORMAT_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form f_format_data.
sort t_output_pur by mtart
ebeln eindt name1 ematn ebelp.
perform f_write_item_header.
describe table t_output_pur lines g_total_records.
loop at t_output_pur.
g_type = t_output_pur-mtart.
g_text = t_output_pur-mtbez.
g_tabix = sy-tabix.
perform f_write_form.
at end of mtart.
if g_tabix eq g_total_records.
exit.
else.
call function 'CONTROL_FORM'
exporting
command = 'NEW-WINDOW'
exceptions
unopened = 1
unstarted = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endif.
endat.
endloop.
clear g_total_records.
perform f_down_load_pur.
endform. " F_FORMAT_DATA
&----
*& Form F_FORMAT_MP_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form f_format_mp_data.
sort t_afvv by aufpl.
sort t_z0cl_batglo by matnr charg.
describe table t_output_mp lines g_total_records.
loop at t_output_mp.
perform f_test_term_sched_date using t_output_mp-ssedd.
read table t_makt with key matnr = t_output_mp-plnbez.
if sy-subrc eq 0.
move t_makt-maktx to t_output_mp-maktx.
endif.
read table t_mara with key matnr = t_output_mp-plnbez.
if sy-subrc eq 0.
move t_mara-mtart to t_output_mp-mtart.
endif.
modify t_output_mp.
READ TABLE T_Z0CL_BATGLO WITH KEY MATNR = T_OUTPUT_MP-PLNBEZ
CHARG = T_OUTPUT_MP-CHARG BINARY SEARCH.
*
IF SY-SUBRC NE 0.
DELETE T_OUTPUT_MP.
CLEAR T_OUTPUT_MP.
ELSE.
MOVE T_Z0CL_BATGLO-PRINTING1 TO T_OUTPUT_MP-PRINTING1.
MODIFY T_OUTPUT_MP TRANSPORTING PRINTING1.
PERFORM F_WRITE_FORM_MP.
ENDIF.
endloop.
endform. " F_FORMAT_MP_DATA
&----
*& Form F_PROCESS_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form f_process_data.
sort t_ekes by ebeln ebelp.
sort t_eket by ebeln ebelp.
sort t_lips by vgbel vgpos.
sort t_makt by matnr.
clear t_lips.
loop at t_eket.
loop at t_ekes where ebeln = t_eket-ebeln
and ebelp = t_eket-ebelp.
perform f_update_qty.
endloop.
if sy-subrc ne 0.
perform f_fill_task_table.
endif.
endloop.
endform. " F_PROCESS_DATA
&----
*& Form F_OPEN_FORM
&----
text
----
--> p1 text
<-- p2 text
----
form f_open_form.
w_itcpo-tdcopies = '1'.
w_itcpo-tddest = 'LOCL'.
w_itcpo-tdprinter = 'NAME'.
w_itcpo-tddelete = 'X'.
w_itcpo-tdimmed = 'X'.
w_itcpo-tddataset = 'NEW'.
W_ITCPO-TDNOPRINT = 'X'.
w_itcpo-tdnewid = 'X'.
w_itcpo-tdpreview = 'X'.
w_itcpo-tdcovtitle = 'QA PLANNING LIST'.
call function 'OPEN_FORM'
exporting
device = 'PRINTER'
dialog = ''
form = g_form_name
language = sy-langu
options = w_itcpo
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
others = 11.
if sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
case sy-subrc.
when '1'.
message e000 with ''(t01).
when '2'.
message e000 with ''(t01).
when '3'.
message e000 with ''(t01).
when '4'.
message e000 with ''(t01).
when '5'.
message e000 with ''(t01).
when '6'.
message e000 with ''(t01).
when '7'.
message e000 with ''(t01).
when '8'.
message e000 with ''(t01).
when '9'.
message e000 with ''(t01).
when '10'.
message e000 with ''(t01).
when '11'.
message e000 with ''(t01).
endcase.
endif.
endform. " F_OPEN_FORM
&----
*& Form F_CLOSE_FORM
&----
text
----
form f_close_form.
call function 'CLOSE_FORM'.
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. " F_CLOSE_FORM
&----
*& Form F_WRITE_FORM
&----
text
----
form f_write_form.
call function 'WRITE_FORM'
exporting
element = 'ITEM_DETAILS'
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
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.
CLEAR G_TABIX.
CLEAR G_TYPE.
endform. " F_WRITE_FORM
&----
*& Form F_FREE_MEMORY
&----
text
----
--> p1 text
<-- p2 text
----
form f_free_memory.
free: t_lips,t_output_pur,t_output_mp,
t_eket,t_ekes,t_afko,t_afvu,t_afvv,
t_mara, t_t134t,t_t024e.
endform. " F_FREE_MEMORY
&----
*& Form F_WRITE_COMPANY
&----
text
----
--> p1 text
<-- p2 text
----
form f_write_item_header.
call function 'WRITE_FORM'
exporting
element = 'ITEM_HEADER'
FUNCTION = 'SET'
TYPE = 'BODY'
window = 'HEADER1'
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.
endform. " F_WRITE_COMPANY
&----
*& Form F_WRITE_FORM_MP
&----
text
----
--> p1 text
<-- p2 text
----
form f_write_form_mp.
loop at t_output_mp.
call function 'WRITE_FORM'
exporting
element = 'ELE1'
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
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.
G_TYPE = T_OUTPUT_MP-MTART.
G_TEXT = T_OUTPUT_MP-MTBEZ.
g_tabix = sy-tabix.
at end of mtart.
if g_tabix eq g_total_records.
exit.
else.
call function 'CONTROL_FORM'
exporting
command = 'NEW-WINDOW'
exceptions
unopened = 1
unstarted = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endif.
endat.
ENDIF.
endloop.
perform f_down_load_mp.
endform. " F_WRITE_FORM_MP
&----
*& Form f_order_data
&----
text
----
--> p1 text
<-- p2 text
----
form f_order_data.
sort t_makt by matnr.
loop at t_afko.
read table t_afvv with key aufpl = t_afko-aufpl binary search.
LOOP AT T_AFVV WHERE AUFPL = T_AFKO-AUFPL.
if sy-subrc eq 0.
t_output_mp-aufnr = t_afko-aufnr.
t_output_mp-plnbez = t_afko-plnbez.
t_output_mp-charg = t_afko-charg.
t_output_mp-gamng = t_afko-gamng.
t_output_mp-gmein = t_afko-gmein.
t_output_mp-ftrmi = t_afko-ftrmi.
t_output_mp-aufpl = t_afko-aufpl.
read table t_makt with key matnr = t_afko-plnbez
spras = sy-langu binary search.
t_output_mp-maktx = t_makt-maktx.
move t_afvv-ssedd to t_output_mp-ssedd.
t_output_mp-spsdd = t_afvv-ssedd.
append t_output_mp.
ENDLOOP.
clear t_output_mp.
else.
delete t_afko. "INDEX SY-INDEX.
endif.
endloop.
endform. " f_order_data
&----
*& Form CHECK_PLANT
&----
text
----
--> p1 text
<-- p2 text
----
form f_check_plant.
select werks from t001w into table t_t001w .
loop at s_plant.
read table t_t001w with key werks = s_plant-low.
if sy-subrc ne 0.
message e020(zw) with 'invalid PLANT'.
endif.
endloop.
endform. " CHECK_PLANT
&----
*& Form F_CHECK_PURCHASE_ORGANIZATION
&----
text
----
--> p1 text
<-- p2 text
----
form f_check_purchase_organization.
select ekorg from t024e into table t_t024e.
loop at s_ekorg.
read table t_t024e with key ekorg = s_ekorg-low.
if sy-subrc ne 0.
message e020(zw) with 'invalid PURCHASE ORGANIZATION'.
endif.
endloop.
endform. " F_CHECK_PURCHASE_ORGANIZATION
&----
*& Form F_FILL_TASK_TABLE
&----
text
----
--> p1 text
<-- p2 text
----
form f_fill_task_table.
move t_eket-ebeln to t_output_pur-ebeln.
move t_eket-ebelp to t_output_pur-ebelp.
move t_eket-eindt to t_output_pur-eindt.
move t_eket-menge to t_output_pur-menge.
move t_eket-meins to t_output_pur-meins.
MOVE T_EKET-EMATN TO T_OUTPUT_PUR-EMATN.
move t_eket-matnr to t_output_pur-matnr.
move t_eket-mtart to t_output_pur-mtart.
MOVE T_EKET-LLIEF TO T_OUTPUT_PUR-LLIEF.
move t_eket-lifnr to t_output_pur-lifnr.
move t_eket-matkl to t_output_pur-matkl.
read table t_makt with key matnr = t_eket-ematn binary search.
if sy-subrc eq 0.
t_output_pur-maktx = t_makt-maktx.
endif.
read table t_lfa1 with key lifnr = t_eket-llief binary search.
move t_lfa1-name1 to t_output_pur-name1.
read table t_t134t with key mtart = t_eket-mtart.
move t_t134t-mtbez to t_output_pur-mtbez.
perform f_spsdate.
*Calculating Test termination Schedule Date
perform f_test_term_sched_date using g_sdate. "T_OUTPUT_PUR-SAPSD
append t_output_pur.
endform. " F_FILL_TASK_TABLE
&----
*& Form F_FILL_FIELD_NAMES
&----
text
----
--> p1 text
<-- p2 text
----
form f_fill_field_names.
t_field_names-fieldname = 'MATERIAL TYPE'.
append t_field_names.
t_field_names-fieldname = 'MATERIAL GROUP'.
append t_field_names.
t_field_names-fieldname = 'ORDER NO'.
append t_field_names.
t_field_names-fieldname = 'ITEM NO'.
append t_field_names.
t_field_names-fieldname = 'MATERIAL NO'.
append t_field_names.
t_field_names-fieldname = 'MATERIAL NO'.
append t_field_names.
t_field_names-fieldname = 'MATERIAL NAME'.
append t_field_names.
t_field_names-fieldname = 'SERIAL NO'.
append t_field_names.
t_field_names-fieldname = 'BATCH NO'.
append t_field_names.
t_field_names-fieldname = 'VENDOR BATCH NO'.
append t_field_names.
t_field_names-fieldname = 'UOM'.
append t_field_names.
t_field_names-fieldname = 'QUANTIY'.
append t_field_names.
t_field_names-fieldname = 'INBOUND DELIVERY DATE'.
append t_field_names.
t_field_names-fieldname = 'SAMPLE PROCUREMENT SCHEDULE DATE'.
append t_field_names.
t_field_names-fieldname = 'TEST ACCEPTANCE DATE'.
append t_field_names.
t_field_names-fieldname = 'REMARKS'.
append t_field_names.
endform. " F_FILL_FIELD_NAMES
&----
*& Form f_down_load_pur
&----
text
----
--> p1 text
<-- p2 text
----
form f_down_load_pur.
perform f_fill_field_names.
call function 'DOWNLOAD'
exporting
BIN_FILESIZE = ' '
CODEPAGE = ' '
filename = 'C:/TEST2'
filetype = 'DAT'
ITEM = ' '
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
SILENT = 'S'
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
ACT_FILENAME =
ACT_FILETYPE =
FILESIZE =
CANCEL =
tables
data_tab = t_output_pur
fieldnames = t_field_names
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
CUSTOMER_ERROR = 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.
endform. " f_down_load_pur
&----
*& Form f_down_load_mp
&----
text
----
--> p1 text
<-- p2 text
----
form f_down_load_mp.
DATA : FILENAME LIKE RLGRAP-FILENAME VALUE 'C:/ QA Planning List'.
DATA : L_FILE_NAME LIKE RLGRAP-FILENAME .
*DATA : FILE LIKE RLGRAP-FILENAME .
CONCATENATE FILENAME s_period-low s_period-high into
L_FILE_NAME.
*MOVE L_FILE_NAME TO FILE.
perform f_fill_field_names.
call function 'DOWNLOAD'
exporting
BIN_FILESIZE = ' '
CODEPAGE = ' '
filename = L_FILE_NAME
filetype = 'DAT'
ITEM = ' '
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
SILENT = 'S'
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
ACT_FILENAME =
ACT_FILETYPE =
FILESIZE =
CANCEL =
tables
data_tab = t_output_mp
fieldnames = t_field_names
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
CUSTOMER_ERROR = 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.
endform. " f_down_load_mp
Message was edited by:
Seshu Maramreddy
‎2007 Jun 15 9:39 PM
see the program and i used print controls to form
<b>w_itcpo-tdcopies = '1'.
w_itcpo-tddest = 'LOCL'.
w_itcpo-tdprinter = 'NAME'.
w_itcpo-tddelete = 'X'.
w_itcpo-tdimmed = 'X'.
w_itcpo-tddataset = 'NEW'.
W_ITCPO-TDNOPRINT = 'X'.
w_itcpo-tdnewid = 'X'.
w_itcpo-tdpreview = 'X'.
w_itcpo-tdcovtitle = 'QA PLANNING LIST'.</b>
the above code should use in open_form FM
report zjpar_Lay no standard page heading
line-size 130 line-count 25 message-id zw.
&----
*& Development ID:PU_DD_313_LJP *
*& *
*& Report ZJPMRPU313 *
*& *
& This program outputs the Test Execution Plan details.The selection-
*& screen contains two radio buttons for Manufactured product and *
& Purchased product.Based on selection of any one of the radio button
*& it will send the details to printer. Before going to output it *
*& shows print preview option. This program send the data to printer. *
&----
*& Change Log: *
*& *
*& Init. Who Date Text *
*& V Seshu 09.06.2003 Initial version *
&----
Include program to declare all the global data.
*INCLUDE ZJPMITOP.
constants : c_plant like ekpo-werks value 'JP01', "Plant
c_pur_org like ekko-ekorg value 'JP30', "Puchasing
"Organization
c_days type i value 1, "
c_hdays type i value 2. "Holidays
"saturday and sunday
----
VARIBLES / INTERNAL TABLES
----
data : g_lead_time type i, "To store lead time
g_weeks type p, "
g_week type i,
g_days like scal-indicator,
g_days1 type i,
g_var1 type i,
g_form_name(20) type c,
g_sdate like sy-datum,
g_total_records type i,
g_type(4) TYPE c, " LIKE MARA-MTART.
g_text like t134t-mtbez,
g_tabix like sy-tabix.
----
DATABASE TABLES
----
tables : mara, "Material Master Data
t134, "Material Type
t134t, "Material Type Descriptions
t001w,
t024e,
marc, "Material Data for Plant
lfa1, "Vendor Master
ekko, "Purchasing Order Header data
ekpo. "Purchasing Order Item data
makt, "Material Descriptions
likp, "Delivery Document Header
lips, "Delivery Document Item
eket. "Scheduling Agreement Schedule Lines
ekes, "Vendor Confirmations
afko, "Order Header Data
afvv, "DB structure of the quantities/dates/values in
"the operation
afvu, "DB structure of the user fields of the
*Operation
z0cl_batglo .
data :w_itcpo like itcpo.
Internal Table to store purchasing product details
data : begin of t_output_pur occurs 0,
mtart like ekpo-mtart,
ebeln like eket-ebeln,
ebelp like eket-ebelp,
matnr like ekpo-matnr,
ematn like ekpo-ematn,
maktx like makt-maktx,
matkl like ekpo-matkl,
etens like ekes-etens,
charg like eket-charg,
licha like eket-licha,
meins like ekpo-meins,
menge(9) type p decimals 3, "LIKE EKET-MENGE,
eindt like eket-eindt,
sapsd like eket-eindt,
webaz like marc-webaz,
tetsd like eket-eindt, " TEST TERMINATION DATE
lifnr like ekko-lifnr,
LLIEF LIKE EKKO-LLIEF,
name1 like lfa1-name1,
mtbez like t134t-mtbez,
end of t_output_pur.
Internal Table to store Manufacturing product details
data : begin of t_output_mp occurs 0,
matkl like mara-matkl,
mtart like mara-mtart,
from_date like sy-datum,
to_date like sy-datum,
aufnr like afko-aufnr,
plnbez like afko-plnbez,
maktx like makt-maktx,
charg like afpo-charg,
gamng like afko-gamng,
gmein like afko-gmein,
ftrmi like afko-ftrmi,
ssedd like afvv-ssedd, "SAMPLE PROCUREMENT DATE
spsdd like afvv-ssedd,
scted like afvv-ssedd,
webaz like marc-webaz,
gltri like afko-gltri,
name1 like lfa1-name1,
aufpl like afko-aufpl,
printing1 like z0cl_batglo-printing1,
end of t_output_mp.
Internal table to store Order header data from AFKO & AFPO tables.
data : begin of t_afko occurs 0,
aufnr like afko-aufnr,
gltri like afko-gltri,
plnbez like afko-plnbez,
charg like afpo-charg,
gamng like afko-gamng,
gmein like afko-gmein,
ftrms like afko-ftrms,
ftrmi like afko-ftrmi,
aufpl like afko-aufpl,
maktx like makt-maktx,
end of t_afko.
Internal table to hold DB structure of the user fields of the
operation
data : begin of t_afvu occurs 0,
aufpl like afvu-aufpl,
aplzl like afvu-aplzl,
usr11 like afvu-usr11,
end of t_afvu.
Internal table to hold DB structure of the quantities/dates/values in
the operation
data : begin of t_afvv occurs 0,
aufpl like afvv-aufpl,
aplzl like afvv-aplzl,
ssedd like afvv-ssedd,
end of t_afvv.
Internal table to hold Vendor confirmation details from EKES table.
data : begin of t_ekes occurs 0,
ebeln like ekes-ebeln,
ebelp like ekes-ebelp,
eindt like ekes-eindt,
etens like ekes-etens,
menge like ekes-menge,
ematn like ekes-ematn,
charg like ekes-charg,
end of t_ekes.
Internal table to store purchased order details from EKKO & EKPO.
data : begin of t_eket occurs 0,
ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
matnr like ekpo-matnr,
ematn like ekpo-ematn,
mtart like ekpo-mtart,
matkl like ekpo-matkl,
meins like ekpo-meins,
lifnr like ekko-lifnr,
ekorg like ekko-ekorg,
werks like ekpo-werks,
llief like ekko-llief,
eindt like eket-eindt,
menge like eket-menge,
end of t_eket.
Internal table to hold Delivery order data
particularly lot information
data : begin of t_lips occurs 0,
vgbel like lips-vgbel,
vgpos like lips-vgpos,
lfimg like lips-lfimg,
vbeln like lips-vbeln,
matnr like lips-matnr,
lifnr like likp-lifnr,
lfdat like likp-lfdat,
charg like lips-charg,
lichn like lips-lichn,
mbdat like lips-mbdat,
end of t_lips.
data: begin of t_t024e occurs 0,
ekorg like t024e-ekorg,
end of t_t024e.
Internal table to hold material names
data : begin of t_makt occurs 0,
matnr like makt-matnr,
maktx like makt-maktx,
spras like makt-spras,
end of t_makt.
Internal table to hold Vendor names
data: begin of t_lfa1 occurs 0,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
end of t_lfa1.
Internal table to hold Lead times for materials
data : begin of t_marc occurs 0,
matnr like marc-matnr,
webaz like marc-webaz,
end of t_marc.
Internal table to hold Batch master details
data : begin of t_z0cl_batglo occurs 0,
matnr like z0cl_batglo-matnr,
charg like z0cl_batglo-charg,
printing1 like z0cl_batglo-printing1,
PRODSITE LIKE Z0CL_BATGLO-PRODSITE,
end of t_z0cl_batglo.
data :begin of t_t134t occurs 0,
mtart like t134t-mtart,
mtbez like t134t-mtbez,
end of t_t134t.
data :begin of t_mara occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
end of t_mara.
data : begin of t_t001w occurs 0,
werks like t001w-werks,
end of t_t001w.
data : begin of t_field_names occurs 0,
fieldname(100) type c,
end of t_field_names.
data: g_table like table of t_output_pur .
----
SELECT-OPTIONS/ PARAMETERS
*
----
selection-screen begin of block qa_planning_list with frame title
text-100.
select-options : s_mtart for mara-mtart no intervals obligatory,
s_period for sy-datum default sy-datum,
s_plant for ekpo-werks default c_plant no intervals,
s_ekorg for ekko-ekorg default c_pur_org no intervals.
selection-screen end of block qa_planning_list.
selection-screen begin of block product_selection with frame title
text-101.
parameters: rb_r1 radiobutton group g1, " Purchased Product
rb_r2 radiobutton group g1. " Manufactured Product
selection-screen end of block product_selection.
*PARAMETER : S_FILE LIKE RLGRAP-FILENAME.
**********************************************************************
*INITIALIZATION.
**********************************************************************
initialization.
**********************************************************************
AT SELECTION-SCREEN : SELECTION SCREEN PRE PROCCESSING.
**********************************************************************
at selection-screen on s_mtart .
perform f_check_mtart.
at selection-screen on s_plant .
perform f_check_plant.
at selection-screen on s_ekorg .
perform f_check_purchase_organization.
**********************************************************************
*START-OF-SELECTION.
**********************************************************************
----
*** MAIN PROCESSING *** *
----
start-of-selection.
set pf-status 'TEST'.
if not rb_r1 is initial.
To get Schedule line data for given selection.
perform f_get_data.
Updating the Schedule line Date and Quantity with Vendor confirmation
data.
perform f_process_data.
else.
To get Manufacturing Product Details
perform f_process_mp.
perform f_order_data.
endif.
************************************************************************
*END-OF-SELECTION.
************************************************************************
end-of-selection.
if not rb_r1 is initial.
g_form_name = 'ZJPMPU313_PO'.
if not t_output_pur[] is initial.
perform f_open_form.
perform f_format_data.
else.
message s016(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'(t01).
exit.
endif.
else.
g_form_name = 'ZJPMPU313_MP'.
perform f_format_mp_data.
if not t_output_mp[] is initial.
perform f_open_form.
perform f_format_mp_data.
perform f_write_form_mp.
else.
message s017(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
exit.
endif.
endif.
*Close Sap script form
perform f_close_form.
*To release all Internal tables memory space
perform f_free_memory.
&----
*& Form F_UPDATE_QTY
&----
Update Quantity, Delivery Date from EKES table to EKET table.
Then move EKET data to Output table.
----
form f_update_qty.
read table t_lips with key vgbel = t_ekes-ebeln
vgpos = t_ekes-ebelp
charg = t_ekes-charg binary search.
if sy-subrc eq 0.
t_eket-menge = t_ekes-menge.
t_eket-eindt = t_ekes-eindt.
MODIFY t_eket TRANSPORTING menge eindt.
move t_lips-charg to t_output_pur-charg.
move t_lips-lichn to t_output_pur-licha.
endif.
move t_eket-ebeln to t_output_pur-ebeln.
move t_eket-ebelp to t_output_pur-ebelp.
MOVE T_EKET-EMATN TO T_OUTPUT_PUR-EMATN.
move t_eket-matnr to t_output_pur-matnr.
move t_eket-meins to t_output_pur-meins.
move t_eket-mtart to t_output_pur-mtart.
move t_ekes-menge to t_output_pur-menge.
move t_ekes-eindt to t_output_pur-eindt.
move t_ekes-etens to t_output_pur-etens.
move t_eket-lifnr to t_output_pur-lifnr.
move t_eket-matkl to t_output_pur-matkl.
MOVE T_EKET-LLIEF TO T_OUTPUT_PUR-LLIEF.
read table t_makt with key matnr = t_eket-ematn binary search.
if sy-subrc eq 0.
t_output_pur-maktx = t_makt-maktx.
endif.
read table t_lfa1 with key lifnr = t_eket-llief binary search.
if sy-subrc eq 0.
move t_lfa1-name1 to t_output_pur-name1.
endif.
read table t_t134t with key mtart = t_eket-mtart.
if sy-subrc eq 0.
move t_t134t-mtbez to t_output_pur-mtbez.
endif.
perform f_spsdate.
*Calculating Test termination Schedule Date
perform f_test_term_sched_date using g_sdate. "T_OUTPUT_PUR-SAPSD.
append t_output_pur.
clear t_output_pur.
clear t_ekes.
clear t_lips.
endform. " F_UPDATE_QTY
&----
*& Form SPSDATE
&----
It calculates Sample Procurement Schedule Date.
Function module Date_Compute_Day return the day that falls in the *
week
----
form f_spsdate.
g_sdate = t_eket-eindt.
call function 'DATE_COMPUTE_DAY'
exporting
date = g_sdate
importing
day = g_days.
g_days2 = g_days.
if g_days gt 5.
g_sdate = g_sdate + c_days + c_hdays.
else.
g_sdate = g_sdate + c_days.
endif.
t_output_pur-sapsd = g_sdate.
endform. " SPSDATE
&----
*& Form PROCESS_MP
&----
This subroutine fetch all necessary data for Production Order
Details
----
form f_process_mp.
select a~aufnr
a~gltri
a~plnbez
b~charg
a~gamng
a~gmein
a~ftrms
a~ftrmi
a~aufpl
from afko as a inner join afpo as b
on aaufnr eq baufnr
into table t_afko
where a~gltri in s_period.
if not t_afko[] is initial.
select aufpl aplzl usr11 from afvu
into table t_afvu for all entries in t_afko
where aufpl = t_afko-aufpl
and usr11 eq 'X'.
else.
message s010(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
endif.
if not t_afvu[] is initial.
select aufpl aplzl ssedd from afvv
into table t_afvv
for all entries in t_afvu
where aufpl = t_afvu-aufpl
and aplzl = t_afvu-aplzl
and ssedd in s_period.
else.
message s010(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
endif.
if not t_afko[] is initial.
select matnr maktx from makt into table t_makt
for all entries in t_afko
where spras eq sy-langu
and matnr eq t_afko-plnbez.
select matnr charg printing1 from z0cl_batglo
into table t_z0cl_batglo
for all entries in t_afko
where matnr eq t_afko-plnbez
and charg eq t_afko-charg.
select matnr mtart from mara into table t_mara
for all entries in t_afko
where matnr eq t_afko-plnbez
and mtart in s_mtart.
else.
message s010(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
endif.
endform. " PROCESS_MP
&----
*& Form F_get_data
&----
This subroutine fetches all necessary data for Purchased Product
details from EKET and EKES tables and store into the internal tables
----
form f_get_data.
select a~ebeln
a~ebelp
a~matnr
a~ematn
a~mtart
a~matkl
a~meins
b~lifnr
b~ekorg
a~werks
b~llief
c~eindt
c~menge
into table t_eket
from ( ( ekpo as a inner join ekko as b
on aebeln eq bebeln )
inner join eket as c
on cebeln eq aebeln
and cebelp eq aebelp )
where a~mtart in s_mtart
and a~werks in s_plant
and b~ekorg in s_ekorg
and c~eindt in s_period.
if sy-subrc eq 0.
sort t_eket by ebeln ebelp.
delete adjacent duplicates from t_eket comparing ebeln ebelp.
select ebeln ebelp eindt etens menge ematn charg
into table t_ekes from ekes
for all entries in t_eket
where eindt in s_period
and ematn eq t_eket-matnr
and ebeln eq t_eket-ebeln
and ebelp eq t_eket-ebelp.
select matnr maktx from makt into table t_makt
for all entries in t_eket
where spras eq sy-langu
and matnr eq t_eket-matnr.
FILLING T_MARC TABLE
select matnr webaz from marc into table t_marc
for all entries in t_eket
where werks in s_plant
and matnr eq t_eket-matnr.
*VENDOR NAME
select lifnr name1 from lfa1 into table t_lfa1
for all entries in t_eket
where lifnr = t_eket-lifnr.
else.
message s010(zw) with 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
MESSAGE S000 WITH 'NO TABLE ENTRIES FOUND FOR GIVEN SELECTION'.
leave list-processing.
endif.
*FILLING THE INTERNAL TABLE T_LIPS.
select avgbel avgpos alfimg avbeln amatnr blifnr b~lfdat
acharg alichn a~mbdat into table t_lips
from lips as a inner join likp as b
on avbeln = bvbeln
where a~mbdat in s_period
and a~vbtyv eq 'V'.
endform. " F_get_data
&----
*& Form CHECK_MTART
&----
This subroutine validates material type which is given by User.
----
-->P_P_MTART text
----
form f_check_mtart.
select mtart mtbez from t134t into table t_t134t where spras eq sy-langu
.
loop at s_mtart.
read table t_t134t with key mtart = s_mtart-low.
if sy-subrc ne 0.
message e020(zw) with 'invalid Material Type'.
message e000 with 'invalid material type'(t01).
endif.
endloop.
endform. " CHECK_MTART
&----
*& Form F_TEST_TERM_SCHED_DATE
&----
This subroutine calculates Test Termination Schedule Date.
----
-->P_t_output_PUR_sapsd text
----
form f_test_term_sched_date using p_t_output_pur_sapsd.
if not rb_r1 is initial.
read table t_marc with key matnr = t_output_pur-ematn .
else.
read table t_marc with key matnr = t_output_mp-plnbez .
endif.
move t_marc-webaz to t_output_pur-webaz.
g_lead_time = t_marc-webaz.
g_weeks = ( trunc( g_lead_time / 5 ) ) * 7.
g_week = g_lead_time mod 5.
call function 'DATE_COMPUTE_DAY'
exporting
date = p_t_output_pur_sapsd
importing
day = g_days.
g_days1 = g_days.
g_var1 = g_days1 + g_week.
if g_var1 > 5 and g_week ne 0.
g_week = g_week + 2.
endif.
g_weeks = g_weeks + g_week.
if not rb_r1 is initial.
t_output_pur-tetsd = p_t_output_pur_sapsd + g_weeks.
else.
t_output_mp-scted = p_t_output_pur_sapsd + g_weeks.
endif.
clear g_sdate.
endform. " F_TEST_TERM_SCHED_DATE
&----
*& Form F_FORMAT_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form f_format_data.
sort t_output_pur by mtart
ebeln eindt name1 ematn ebelp.
perform f_write_item_header.
describe table t_output_pur lines g_total_records.
loop at t_output_pur.
g_type = t_output_pur-mtart.
g_text = t_output_pur-mtbez.
g_tabix = sy-tabix.
perform f_write_form.
at end of mtart.
if g_tabix eq g_total_records.
exit.
else.
call function 'CONTROL_FORM'
exporting
command = 'NEW-WINDOW'
exceptions
unopened = 1
unstarted = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endif.
endat.
endloop.
clear g_total_records.
perform f_down_load_pur.
endform. " F_FORMAT_DATA
&----
*& Form F_FORMAT_MP_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form f_format_mp_data.
sort t_afvv by aufpl.
sort t_z0cl_batglo by matnr charg.
describe table t_output_mp lines g_total_records.
loop at t_output_mp.
perform f_test_term_sched_date using t_output_mp-ssedd.
read table t_makt with key matnr = t_output_mp-plnbez.
if sy-subrc eq 0.
move t_makt-maktx to t_output_mp-maktx.
endif.
read table t_mara with key matnr = t_output_mp-plnbez.
if sy-subrc eq 0.
move t_mara-mtart to t_output_mp-mtart.
endif.
modify t_output_mp.
READ TABLE T_Z0CL_BATGLO WITH KEY MATNR = T_OUTPUT_MP-PLNBEZ
CHARG = T_OUTPUT_MP-CHARG BINARY SEARCH.
*
IF SY-SUBRC NE 0.
DELETE T_OUTPUT_MP.
CLEAR T_OUTPUT_MP.
ELSE.
MOVE T_Z0CL_BATGLO-PRINTING1 TO T_OUTPUT_MP-PRINTING1.
MODIFY T_OUTPUT_MP TRANSPORTING PRINTING1.
PERFORM F_WRITE_FORM_MP.
ENDIF.
endloop.
endform. " F_FORMAT_MP_DATA
&----
*& Form F_PROCESS_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form f_process_data.
sort t_ekes by ebeln ebelp.
sort t_eket by ebeln ebelp.
sort t_lips by vgbel vgpos.
sort t_makt by matnr.
clear t_lips.
loop at t_eket.
loop at t_ekes where ebeln = t_eket-ebeln
and ebelp = t_eket-ebelp.
perform f_update_qty.
endloop.
if sy-subrc ne 0.
perform f_fill_task_table.
endif.
endloop.
endform. " F_PROCESS_DATA
&----
*& Form F_OPEN_FORM
&----
text
----
--> p1 text
<-- p2 text
----
form f_open_form.
w_itcpo-tdcopies = '1'.
w_itcpo-tddest = 'LOCL'.
w_itcpo-tdprinter = 'NAME'.
w_itcpo-tddelete = 'X'.
w_itcpo-tdimmed = 'X'.
w_itcpo-tddataset = 'NEW'.
W_ITCPO-TDNOPRINT = 'X'.
w_itcpo-tdnewid = 'X'.
w_itcpo-tdpreview = 'X'.
w_itcpo-tdcovtitle = 'QA PLANNING LIST'.
call function 'OPEN_FORM'
exporting
device = 'PRINTER'
dialog = ''
form = g_form_name
language = sy-langu
options = w_itcpo
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
others = 11.
if sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
case sy-subrc.
when '1'.
message e000 with ''(t01).
when '2'.
message e000 with ''(t01).
when '3'.
message e000 with ''(t01).
when '4'.
message e000 with ''(t01).
when '5'.
message e000 with ''(t01).
when '6'.
message e000 with ''(t01).
when '7'.
message e000 with ''(t01).
when '8'.
message e000 with ''(t01).
when '9'.
message e000 with ''(t01).
when '10'.
message e000 with ''(t01).
when '11'.
message e000 with ''(t01).
endcase.
endif.
endform. " F_OPEN_FORM
&----
*& Form F_CLOSE_FORM
&----
text
----
form f_close_form.
call function 'CLOSE_FORM'.
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. " F_CLOSE_FORM
&----
*& Form F_WRITE_FORM
&----
text
----
form f_write_form.
call function 'WRITE_FORM'
exporting
element = 'ITEM_DETAILS'
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
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.
CLEAR G_TABIX.
CLEAR G_TYPE.
endform. " F_WRITE_FORM
&----
*& Form F_FREE_MEMORY
&----
text
----
--> p1 text
<-- p2 text
----
form f_free_memory.
free: t_lips,t_output_pur,t_output_mp,
t_eket,t_ekes,t_afko,t_afvu,t_afvv,
t_mara, t_t134t,t_t024e.
endform. " F_FREE_MEMORY
&----
*& Form F_WRITE_COMPANY
&----
text
----
--> p1 text
<-- p2 text
----
form f_write_item_header.
call function 'WRITE_FORM'
exporting
element = 'ITEM_HEADER'
FUNCTION = 'SET'
TYPE = 'BODY'
window = 'HEADER1'
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.
endform. " F_WRITE_COMPANY
&----
*& Form F_WRITE_FORM_MP
&----
text
----
--> p1 text
<-- p2 text
----
form f_write_form_mp.
loop at t_output_mp.
call function 'WRITE_FORM'
exporting
element = 'ELE1'
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
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.
G_TYPE = T_OUTPUT_MP-MTART.
G_TEXT = T_OUTPUT_MP-MTBEZ.
g_tabix = sy-tabix.
at end of mtart.
if g_tabix eq g_total_records.
exit.
else.
call function 'CONTROL_FORM'
exporting
command = 'NEW-WINDOW'
exceptions
unopened = 1
unstarted = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endif.
endat.
ENDIF.
endloop.
perform f_down_load_mp.
endform. " F_WRITE_FORM_MP
&----
*& Form f_order_data
&----
text
----
--> p1 text
<-- p2 text
----
form f_order_data.
sort t_makt by matnr.
loop at t_afko.
read table t_afvv with key aufpl = t_afko-aufpl binary search.
LOOP AT T_AFVV WHERE AUFPL = T_AFKO-AUFPL.
if sy-subrc eq 0.
t_output_mp-aufnr = t_afko-aufnr.
t_output_mp-plnbez = t_afko-plnbez.
t_output_mp-charg = t_afko-charg.
t_output_mp-gamng = t_afko-gamng.
t_output_mp-gmein = t_afko-gmein.
t_output_mp-ftrmi = t_afko-ftrmi.
t_output_mp-aufpl = t_afko-aufpl.
read table t_makt with key matnr = t_afko-plnbez
spras = sy-langu binary search.
t_output_mp-maktx = t_makt-maktx.
move t_afvv-ssedd to t_output_mp-ssedd.
t_output_mp-spsdd = t_afvv-ssedd.
append t_output_mp.
ENDLOOP.
clear t_output_mp.
else.
delete t_afko. "INDEX SY-INDEX.
endif.
endloop.
endform. " f_order_data
&----
*& Form CHECK_PLANT
&----
text
----
--> p1 text
<-- p2 text
----
form f_check_plant.
select werks from t001w into table t_t001w .
loop at s_plant.
read table t_t001w with key werks = s_plant-low.
if sy-subrc ne 0.
message e020(zw) with 'invalid PLANT'.
endif.
endloop.
endform. " CHECK_PLANT
&----
*& Form F_CHECK_PURCHASE_ORGANIZATION
&----
text
----
--> p1 text
<-- p2 text
----
form f_check_purchase_organization.
select ekorg from t024e into table t_t024e.
loop at s_ekorg.
read table t_t024e with key ekorg = s_ekorg-low.
if sy-subrc ne 0.
message e020(zw) with 'invalid PURCHASE ORGANIZATION'.
endif.
endloop.
endform. " F_CHECK_PURCHASE_ORGANIZATION
&----
*& Form F_FILL_TASK_TABLE
&----
text
----
--> p1 text
<-- p2 text
----
form f_fill_task_table.
move t_eket-ebeln to t_output_pur-ebeln.
move t_eket-ebelp to t_output_pur-ebelp.
move t_eket-eindt to t_output_pur-eindt.
move t_eket-menge to t_output_pur-menge.
move t_eket-meins to t_output_pur-meins.
MOVE T_EKET-EMATN TO T_OUTPUT_PUR-EMATN.
move t_eket-matnr to t_output_pur-matnr.
move t_eket-mtart to t_output_pur-mtart.
MOVE T_EKET-LLIEF TO T_OUTPUT_PUR-LLIEF.
move t_eket-lifnr to t_output_pur-lifnr.
move t_eket-matkl to t_output_pur-matkl.
read table t_makt with key matnr = t_eket-ematn binary search.
if sy-subrc eq 0.
t_output_pur-maktx = t_makt-maktx.
endif.
read table t_lfa1 with key lifnr = t_eket-llief binary search.
move t_lfa1-name1 to t_output_pur-name1.
read table t_t134t with key mtart = t_eket-mtart.
move t_t134t-mtbez to t_output_pur-mtbez.
perform f_spsdate.
*Calculating Test termination Schedule Date
perform f_test_term_sched_date using g_sdate. "T_OUTPUT_PUR-SAPSD
append t_output_pur.
endform. " F_FILL_TASK_TABLE
&----
*& Form F_FILL_FIELD_NAMES
&----
text
----
--> p1 text
<-- p2 text
----
form f_fill_field_names.
t_field_names-fieldname = 'MATERIAL TYPE'.
append t_field_names.
t_field_names-fieldname = 'MATERIAL GROUP'.
append t_field_names.
t_field_names-fieldname = 'ORDER NO'.
append t_field_names.
t_field_names-fieldname = 'ITEM NO'.
append t_field_names.
t_field_names-fieldname = 'MATERIAL NO'.
append t_field_names.
t_field_names-fieldname = 'MATERIAL NO'.
append t_field_names.
t_field_names-fieldname = 'MATERIAL NAME'.
append t_field_names.
t_field_names-fieldname = 'SERIAL NO'.
append t_field_names.
t_field_names-fieldname = 'BATCH NO'.
append t_field_names.
t_field_names-fieldname = 'VENDOR BATCH NO'.
append t_field_names.
t_field_names-fieldname = 'UOM'.
append t_field_names.
t_field_names-fieldname = 'QUANTIY'.
append t_field_names.
t_field_names-fieldname = 'INBOUND DELIVERY DATE'.
append t_field_names.
t_field_names-fieldname = 'SAMPLE PROCUREMENT SCHEDULE DATE'.
append t_field_names.
t_field_names-fieldname = 'TEST ACCEPTANCE DATE'.
append t_field_names.
t_field_names-fieldname = 'REMARKS'.
append t_field_names.
endform. " F_FILL_FIELD_NAMES
&----
*& Form f_down_load_pur
&----
text
----
--> p1 text
<-- p2 text
----
form f_down_load_pur.
perform f_fill_field_names.
call function 'DOWNLOAD'
exporting
BIN_FILESIZE = ' '
CODEPAGE = ' '
filename = 'C:/TEST2'
filetype = 'DAT'
ITEM = ' '
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
SILENT = 'S'
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
ACT_FILENAME =
ACT_FILETYPE =
FILESIZE =
CANCEL =
tables
data_tab = t_output_pur
fieldnames = t_field_names
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
CUSTOMER_ERROR = 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.
endform. " f_down_load_pur
&----
*& Form f_down_load_mp
&----
text
----
--> p1 text
<-- p2 text
----
form f_down_load_mp.
DATA : FILENAME LIKE RLGRAP-FILENAME VALUE 'C:/ QA Planning List'.
DATA : L_FILE_NAME LIKE RLGRAP-FILENAME .
*DATA : FILE LIKE RLGRAP-FILENAME .
CONCATENATE FILENAME s_period-low s_period-high into
L_FILE_NAME.
*MOVE L_FILE_NAME TO FILE.
perform f_fill_field_names.
call function 'DOWNLOAD'
exporting
BIN_FILESIZE = ' '
CODEPAGE = ' '
filename = L_FILE_NAME
filetype = 'DAT'
ITEM = ' '
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
SILENT = 'S'
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
ACT_FILENAME =
ACT_FILETYPE =
FILESIZE =
CANCEL =
tables
data_tab = t_output_mp
fieldnames = t_field_names
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
CUSTOMER_ERROR = 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.
endform. " f_down_load_mp
Message was edited by:
Seshu Maramreddy
‎2007 Jun 16 1:46 PM