‎2006 Aug 21 3:09 AM
hi SDNs,
i have problem with my report..
thing is : in my selection-screen, there are screen elements like : werks, storage location, budat, material...etc.,
if i give matnr,werks ,lgort, and date : the report is giving correct result. where as if i don't give storage location the output is giving less records...
where could be the problem? can any one help me out??
its very urgent...
thanking you,
Ramakrishna S
‎2006 Aug 21 3:19 AM
hi,
I think you have written your select similar to .
Select...
...
where lgort = p_lgort.
So, when you dont give storage location, this condition doesnt get satisfied. So, you are getting less records.
If you to get all records, change the lgort to select-option instead of a parameter.
tables : t001l.
Select-options : s_lgort for t001l-lgort.
Select...
...
where lgort in s_lgort.
Regards,
Sailaja.
‎2006 Aug 21 3:26 AM
hai Sailaja,
thank u..,
but i am using <b>select-options</b> only...
<b>here i am getting data correctly. but based on some condition i am deleting the records ..
i will send the code... could you pls be in touch. it will take time to send ..
thanking you
‎2006 Aug 21 3:28 AM
just post your select statements and your deletes.
Message was edited by: Neil Woodruff
‎2006 Aug 21 4:56 AM
hi
good
the data besically select from the database as per your data in the selection screen bcz as per the selection screen data you have written your select statement, if you r not entering the storage location naturally less data will fetch from the database, there is nothing to worry.If you want to get the actual data than you have to give the storage location.
thanks
mrutyun
‎2006 Aug 21 5:47 AM
hi all,
thanks .,
my select stmt::
SELECT a~mblnr
a~mjahr
a~zeile
a~bwart
a~matnr
a~werks
a~lgort
a~shkzg
a~bwtar
a~ebeln
a~ps_psp_pnr
b~budat
a~equnr "MOD-001
FROM mseg AS a JOIN mkpf AS b
ON amblnr = bmblnr AND
amjahr = bmjahr
INTO TABLE lt_doc
WHERE a~matnr IN s_matnr AND
a~sobkz IN s_sobkz AND
a~werks EQ p_werks AND
a~lgort IN s_lgort AND
a~bwtar IN s_bwtar AND
b~budat IN s_budat AND
b~cpudt IN s_cpudt AND
a~bwart IN s_bwart .
from this data i have to delete info accordingly based on storage loc and plant:
here from final table:
get werks, lgort from eqbs.
1. check with werks value with this value, if not matches just delete
2. and then same for lgort
LOOP AT lt_final INTO lw_final.
CLEAR lf_final_sernr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lw_final-sernr
IMPORTING
output = lf_final_sernr.
CLEAR : lf_lgort, lf_werks.
*----
*----
SELECT b_werk
into lf_werks
FROM eqbs
WHERE equnr = lf_final_sernr .
IF ( lf_werks NE p_werks ).
DELETE lt_final.
ENDIF.
ENDSELECT.
IF sy-subrc <> 0.
DELETE lt_final.
ENDIF.
ENDLOOP.
IF s_lgort[] IS NOT INITIAL.
LOOP AT lt_final INTO lw_final.
CLEAR lf_lgort.
SELECT b_lager
INTO lf_lgort
FROM eqbs
WHERE equnr = lf_final_sernr .
IF ( lf_lgort NOT IN s_lgort ) .
DELETE lt_final.
ENDIF.
ENDSELECT.
IF sy-subrc <> 0.
DELETE lt_final.
ENDIF.
ENDLOOP.
ENDIF.
if needs i will send my code(program)
‎2006 Aug 21 6:01 AM
is it only the s_lgort which is empty or is P_WERKS empty too? Because If P_werks is empty the results with non-space werks values will of course be deleted.
‎2006 Aug 21 6:59 AM
see Neil Woodruff ,
if i give lgort, it is working fine but
if i dont' give any value it is giving less records..
i am talking abt storage location not plant. i am givning plant always . pls chekc it out
ramu
‎2006 Aug 21 7:16 AM
hi all,
my report:
in this <b>zmmr_stockdetails_variables</b> is include. this is after this code:
----
INCLUDE: DATA DECLARATION / SELECTION-SCREEN / INITIALIZATION / SCREEN EVENTS
----
include zmmr_stockdetails_variables .
----
START-OF-SELECTION
----
start-of-selection.
perform fr_start_of_selection.
&----
*& Form fr_start_of_selection
&----
form fr_start_of_selection .
data: lt_doc type tt_doc,
lt_ser03 type tt_ser03,
lt_objk type tt_objk,
lt_final type tt_final,
lt_ftp type tt_ftp,
lt_equi type tt_equi,
lt_doc_temp type tt_doc_temp.
perform fr_get_material_doc_data changing lt_doc
lt_doc_temp
lt_ser03
lt_objk
lt_equi.
if ( lt_doc[] is not initial ) and ( lt_objk[] is not initial ).
perform fr_final_output_data using lt_objk
lt_doc
lt_doc_temp
changing lt_final
lt_ftp.
endif.
if p_ftp = 'X' and ( lt_ftp is not initial ).
*--Send data to FTP
perform ftp_data using lt_ftp.
elseif ( lt_final is not initial ).
*--Display data in ALV with SUBTOTAL
perform fr_display_data using lt_final.
elseif ( lt_final is initial ).
*--Display NO DATA
perform fr_display_no_data .
endif.
endform. " fr_start_of_selection
&----
*& Form fr_get_material_doc_data
&----
form fr_get_material_doc_data changing lt_doc type tt_doc
lt_doc_temp type tt_doc_temp
lt_ser03 type tt_ser03
lt_objk type tt_objk
lt_equi type tt_equi.
data : lw_doc type tw_doc,
lw_doc_temp type tw_doc_temp,
lw_ser03 type tw_ser03,
lw_objk type tw_objk,
lw_objk1 type tw_objk,
lt_objk1 type tt_objk,
lw_equi type tw_equi.
if p_ftp = 'X'.
if s_cpudt is initial.
s_cpudt-sign = 'I'.
s_cpudt-option = 'EQ'.
s_cpudt-low = sy-datum - 1.
append s_cpudt.
endif.
endif.
IF s_lgort[] IS NOT INITIAL.
SELECT a~mblnr
a~mjahr
a~zeile
a~bwart
a~matnr
a~werks
a~lgort
a~shkzg
a~bwtar
a~ebeln
a~ps_psp_pnr
b~budat
a~equnr "MOD-001
FROM mseg AS a JOIN mkpf AS b
ON amblnr = bmblnr AND
amjahr = bmjahr
INTO TABLE lt_doc
WHERE a~matnr IN s_matnr AND
a~sobkz IN s_sobkz AND
a~werks EQ p_werks AND
a~lgort IN s_lgort AND
a~bwtar IN s_bwtar AND
b~budat IN s_budat AND
b~cpudt IN s_cpudt AND
a~bwart IN s_bwart .
*
ELSE.
select a~mblnr
a~mjahr
a~zeile
a~bwart
a~matnr
a~werks
a~lgort
a~shkzg
a~bwtar
a~ebeln
a~ps_psp_pnr
b~budat
a~equnr "MOD-001
from mseg as a join mkpf as b
on amblnr = bmblnr and
amjahr = bmjahr
into table lt_doc
where a~matnr in s_matnr and
a~sobkz in s_sobkz and
a~werks eq p_werks and
a~lgort in s_lgort and
a~bwtar in s_bwtar and
b~budat in s_budat and
b~cpudt in s_cpudt and
a~bwart in s_bwart .
ENDIF.
if ( lt_doc[] is not initial ).
select obknr
mblnr
mjahr
zeile
bwart
datum
uzeit
anzsn
werk
lagerort
from ser03
into table lt_ser03
for all entries in lt_doc
where mblnr = lt_doc-mblnr and
mjahr = lt_doc-mjahr and
zeile = lt_doc-zeile and
werk = lt_doc-werks and
lagerort = lt_doc-lgort .
endif.
if ( lt_ser03[] is not initial ).
select obknr
equnr
sernr
matnr
from objk
into table lt_objk1
for all entries in lt_ser03
where obknr = lt_ser03-obknr and
matnr in s_matnr.
endif.
if ( lt_objk1[] is not initial ).
select equnr from equi
into table lt_equi
for all entries in lt_objk1
where equnr = lt_objk1-equnr and
matnr = lt_objk1-matnr and
eqtyp in s_eqtyp.
endif.
sort lt_objk1 by obknr equnr.
sort lt_equi by equnr.
*-Append all data to OBJK for the EQNR
loop at lt_objk1 into lw_objk1.
read table lt_equi into lw_equi with key equnr = lw_objk1-equnr.
if sy-subrc eq 0.
append lw_objk1 to lt_objk.
clear: lw_objk1, lw_equi.
endif.
endloop.
*-Modify LT_DOC with Object list number(OBKNR) from SER03
loop at lt_ser03 into lw_ser03.
read table lt_doc into lw_doc with key mblnr = lw_ser03-mblnr
zeile = lw_ser03-zeile
mjahr = lw_ser03-mjahr.
if ( sy-subrc = 0 ) and ( lw_ser03-obknr is not initial ).
lw_doc-obknr = lw_ser03-obknr.
lw_doc-datum = lw_ser03-datum.
lw_doc-uzeit = lw_ser03-uzeit.
modify lt_doc from lw_doc transporting obknr datum uzeit where mblnr = lw_ser03-mblnr and
zeile = lw_ser03-zeile and
mjahr = lw_ser03-mjahr."#EC *
endif.
clear: lw_doc, lw_ser03.
endloop.
----
*-Modify LT_DOC_TEMP with (MBLNR / SERNR / BWART / TIME ) from SER03
sort lt_objk by obknr.
loop at lt_objk into lw_objk.
read table lt_ser03 into lw_ser03 with key obknr = lw_objk-obknr.
if ( sy-subrc = 0 ) .
lw_doc_temp-mblnr = lw_ser03-mblnr.
lw_doc_temp-mjahr = lw_ser03-mjahr.
lw_doc_temp-sernr = lw_objk-sernr.
lw_doc_temp-bwart = lw_ser03-bwart.
lw_doc_temp-datum = lw_ser03-datum.
lw_doc_temp-uzeit = lw_ser03-uzeit.
lw_doc_temp-werk = lw_ser03-werk.
lw_doc_temp-plant = lw_ser03-lagerort.
append lw_doc_temp to lt_doc_temp .
clear: lw_doc_temp, lw_ser03, lw_objk .
endif.
endloop.
sort lt_doc_temp by sernr.
*--If EXTRA entries deleted as per LATEST DOC, then Comment this below line.
delete adjacent duplicates from lt_doc_temp comparing sernr.
*--End of - If EXTRA entries deleted as per LATEST DOC, then Comment this line.
----
*Delete itab where OBKNR is initial.
delete lt_doc[] where obknr = ' '.
sort lt_doc[] by matnr werks.
loop at lt_doc into lw_doc.
if ( lw_doc-werks is not initial ).
select name1
up to 1 rows
into lw_doc-name1
from t001w
where werks = lw_doc-werks.
endselect.
endif.
if ( lw_doc-matnr is not initial ).
select maktx
up to 1 rows
into lw_doc-maktx
from makt
where matnr = lw_doc-matnr.
endselect.
endif.
if ( lw_doc-werks is not initial ) and
( lw_doc-lgort is not initial ).
select agency
up to 1 rows
into lw_doc-agency
from zcrmtosap
where werks = lw_doc-werks and
lgort = lw_doc-lgort.
endselect.
endif.
if ( lw_doc-name1 is not initial ) or ( lw_doc-maktx is not initial ) or
( lw_doc-agency is not initial ).
modify lt_doc from lw_doc transporting name1 maktx agency ."#EC *
endif.
clear: lw_doc.
endloop.
sort lt_objk[] by obknr equnr.
endform. " fr_get_data_from_mseg
&----
*& Form fr_final_output_data
&----
form fr_final_output_data using lt_objk type tt_objk
lt_doc type tt_doc
lt_doc_temp type tt_doc_temp
changing lt_final type tt_final
lt_ftp type tt_ftp.
data : lw_doc type tw_doc,
lw_doc_temp type tw_doc_temp,
lw_objk type tw_objk,
lw_final type tw_final,
lt_final_temp type tt_final,
lw_ftp type tw_ftp,
lf_mblnr type mblnr,
lf_sernr type gernr,
lf_final_sernr type gernr,
lf_final_matnr type matnr,
lf_doc_sernr type gernr,
lf_doc_matnr type matnr,
lf_bwart type bwart,
lf_count type i,
lf_mjahr type mjahr,
lf_maktx type maktx,
lf_budat type budat,
lf_uzeit type uzeit,
lf_ebeln type bstnr,
lf_werks type werks_d,
lf_name1 type name1,
lf_lgort type lgort_d,
lf_shkzg type shkzg,
lf_agency type sgtxt,
lf_zeile type mblpo,
lf_obknr type objknr,
lf_bwtar type bwtar,
lf_psp type ps_psp_pnr.
sort lt_doc[] by obknr.
sort lt_objk[] by obknr.
*-append FINAL table with all fields from OBJK / SER03 tables
loop at lt_objk into lw_objk.
read table lt_doc into lw_doc with key obknr = lw_objk-obknr.
if sy-subrc = 0.
lw_final-matnr = lw_doc-matnr.
lw_final-sernr = lw_objk-sernr.
lw_final-budat = lw_doc-budat.
lw_final-uzeit = lw_doc-uzeit.
lw_final-ebeln = lw_doc-ebeln.
lw_final-werks = lw_doc-werks.
lw_final-lgort = lw_doc-lgort.
lw_final-mblnr = lw_doc-mblnr.
lw_final-zeile = lw_doc-zeile.
lw_final-obknr = lw_objk-obknr.
lw_final-bwtar = lw_doc-bwtar.
lw_final-ps_psp_pnr = lw_doc-ps_psp_pnr.
lw_final-name1 = lw_doc-name1.
lw_final-maktx = lw_doc-maktx.
lw_final-agency = lw_doc-agency.
lw_final-bwart = lw_doc-bwart.
lw_final-count = '1'.
append lw_final to lt_final.
clear: lw_final, lw_doc.
endif.
endloop.
*-Modify FINAL table with Year / Debit-Credit Indicator
if ( lt_final[] is not initial ) .
loop at lt_final into lw_final.
read table lt_doc into lw_doc with key mblnr = lw_final-mblnr
zeile = lw_final-zeile.
if sy-subrc = 0.
lw_final-mjahr = lw_doc-mjahr.
lw_final-shkzg = lw_doc-shkzg.
if ( lw_final-mjahr is not initial ) or ( lw_final-shkzg is not initial ).
modify lt_final from lw_final transporting mjahr shkzg.
endif.
clear: lw_final, lw_doc.
endif.
endloop.
*-Modify lt_doc FROM final table w.r.t ESN number
loop at lt_doc into lw_doc.
read table lt_final into lw_final with key mblnr = lw_doc-mblnr.
if sy-subrc = 0.
lw_doc-sernr = lw_final-sernr.
if ( lw_doc-sernr is not initial ).
modify lt_doc from lw_doc transporting sernr.
endif.
clear: lw_doc, lw_final.
endif.
endloop.
----
*--Remove Preceding ZEROS from SERNR of LT_FINAL
loop at lt_final into lw_final.
clear: lf_final_sernr.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = lw_final-sernr
importing
output = lf_final_sernr.
if ( lf_final_sernr is not initial ).
lw_final-sernr = lf_final_sernr.
modify lt_final from lw_final transporting sernr.
clear: lw_final-sernr.
endif.
*--Remove Preceding ZEROS from MATNR of LT_FINAL
clear: lf_final_matnr.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = lw_final-matnr
importing
output = lf_final_matnr.
if ( lf_final_matnr is not initial ).
lw_final-matnr = lf_final_matnr.
modify lt_final from lw_final transporting matnr.
clear: lw_final-matnr.
endif.
endloop.
*--Remove Preceding ZEROS from SERNR of LT_DOC
loop at lt_doc into lw_doc.
clear: lf_doc_sernr.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = lw_doc-sernr
importing
output = lf_doc_sernr.
if ( lf_doc_sernr is not initial ).
lw_doc-sernr = lf_doc_sernr .
modify lt_doc from lw_doc transporting sernr.
clear: lw_doc-sernr.
endif.
*--Remove Preceding ZEROS from MATNR of LT_DOC
clear: lf_doc_matnr.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = lw_doc-matnr
importing
output = lf_doc_matnr.
if ( lf_doc_matnr is not initial ).
lw_doc-matnr = lf_doc_matnr.
modify lt_doc from lw_doc transporting matnr.
clear: lw_doc-matnr.
endif.
endloop.
----
*For given ESN select the first Material Document (Latest Document) from the sorted list,
*check for the Movement type of that document and if the Movement type falls in any of
*the following then remove the ESN and its Material Documents.
*Movement types for which ESN needs to be deleted: 102,201,221,261,351,502,562,601,Y52,Z52
*Consider the Debit / Credit Indicator (MSEG_SHKZG)= 'S' (ignore H) for the following
*Movement Types. 311, 312, 313, 314, 352, 411, 412, 415, 416.
----
sort lt_final[] descending by shkzg sernr budat uzeit mblnr." MOD-01
sort lt_doc[] by bwart.
loop at lt_final into lw_final.
lf_sernr = lw_final-sernr.
lf_mblnr = lw_final-mblnr.
lf_budat = lw_final-budat.
lf_uzeit = lw_final-uzeit.
lf_ebeln = lw_final-ebeln.
lf_werks = lw_final-werks.
lf_name1 = lw_final-name1.
lf_lgort = lw_final-lgort.
lf_shkzg = lw_final-shkzg.
lf_agency = lw_final-agency.
lf_zeile = lw_final-zeile.
lf_obknr = lw_final-obknr.
lf_bwart = lw_final-bwart.
lf_bwtar = lw_final-bwtar.
lf_psp = lw_final-ps_psp_pnr.
lf_count = lw_final-count.
*-For given ESN select the first Material Document (Latest Document)
at new sernr.
read table lt_doc into lw_doc with key mblnr = lf_mblnr
lgort = lf_lgort.
if sy-subrc = 0.
move lf_mblnr to lw_final-mblnr.
move lf_sernr to lw_final-sernr.
move lf_budat to lw_final-budat.
move lf_uzeit to lw_final-uzeit.
move lf_ebeln to lw_final-ebeln.
move lf_werks to lw_final-werks.
move lf_name1 to lw_final-name1.
move lf_lgort to lw_final-lgort.
move lf_shkzg to lw_final-shkzg.
move lf_agency to lw_final-agency.
move lf_zeile to lw_final-zeile.
move lf_obknr to lw_final-obknr.
move lf_bwart to lw_final-bwart.
move lf_bwtar to lw_final-bwtar.
move lf_psp to lw_final-ps_psp_pnr.
move lf_count to lw_final-count.
append lw_final to lt_final_temp.
clear: lw_final, lf_mblnr, lf_sernr, lf_budat, lf_ebeln, lf_werks, lf_name1, lf_shkzg,
lf_lgort, lf_agency, lf_zeile, lf_obknr, lf_bwart, lf_bwtar, lf_psp, lf_count.
endif.
endat.
endloop.
refresh: lt_final[].
lt_final[] = lt_final_temp[].
refresh: lt_final_temp[].
if ( lt_final[] is not initial ) .
sort lt_final[] by bwart.
*Movement types for which ESN needs to be deleted: 102,201,221,261,351,502,562,601,Y52,Z52
delete lt_final[] where ( ( bwart = '102' ) or ( bwart = '201' ) or ( bwart = '221' ) or
( bwart = '261' ) or ( bwart = '351' ) or ( bwart = '452' ) or
( bwart = '502' ) or ( bwart = '562' ) or ( bwart = '601' ) or
( bwart = 'Y52' ) or ( bwart = 'Z52' ) ).
if ( lt_final[] is not initial ) .
*Consider the Debit / Credit Indicator (MSEG_SHKZG)= 'S' (ignore H) for the following
*Movement Types. 311, 312, 313, 314, 352, 411, 412, 415, 416.
sort lt_final[] by bwart shkzg.
delete lt_final[] where ( bwart = '311' and shkzg = 'H' ) or
( bwart = '312' and shkzg = 'H' ) or
( bwart = '313' and shkzg = 'H' ) or
( bwart = '314' and shkzg = 'H' ) or
( bwart = '352' and shkzg = 'H' ) or
( bwart = '411' and shkzg = 'H' ) or
( bwart = '412' and shkzg = 'H' ) or
( bwart = '415' and shkzg = 'H' ) or
( bwart = '416' and shkzg = 'H' ).
endif.
endif.
*==================================================================================================
*START OF MOD-01
*Delete EXTRA entries, when the SAME ESN number is appearing for different MBLNR / Storage Location.
sort lt_final by budat descending.
sort lt_final by sernr .
delete adjacent duplicates from lt_final comparing sernr.
loop at lt_final into lw_final.
clear lf_final_sernr.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = lw_final-sernr
importing
output = lf_final_sernr.
clear : lf_lgort, lf_werks.
*----
*----
select b_werk
into lf_werks
from eqbs
where equnr = lf_final_sernr .
if sy-subrc = 0 .
if ( lf_werks ne p_werks ).
delete lt_final.
endif.
endif.
endselect.
if sy-subrc <> 0.
delete lt_final.
endif.
endloop.
if s_lgort[] is not initial.
loop at lt_final into lw_final.
clear lf_lgort.
select b_lager
into lf_lgort
from eqbs
where equnr = lf_final_sernr .
if ( lf_lgort not in s_lgort ) .
delete lt_final.
endif.
endselect.
if sy-subrc <> 0.
delete lt_final.
endif.
endloop.
endif.
if s_budat[] is not initial.
delete lt_final where budat not in s_budat.
endif.
*- -
*----
*END OF MOD-01
*============================================================================
loop at lt_final into lw_final.
concatenate lw_final-matnr ',' into lw_ftp-matnr.
concatenate lw_final-sernr ',' into lw_ftp-sernr.
concatenate lw_final-budat ',' into lw_ftp-budat.
concatenate lw_final-ebeln ',' into lw_ftp-ebeln.
concatenate lw_final-werks ',' into lw_ftp-werks.
concatenate lw_final-lgort ',' into lw_ftp-lgort.
concatenate lw_final-mblnr ',' into lw_ftp-mblnr.
concatenate lw_final-bwtar ',' into lw_ftp-bwtar.
concatenate lw_final-bwart ',' into lw_ftp-bwart.
call function 'CONVERSION_EXIT_ABPSP_OUTPUT'
exporting
input = lw_final-ps_psp_pnr
importing
output = lw_ftp-ps_psp_pnr.
concatenate lw_final-name1 ',' into lw_ftp-name1.
concatenate lw_final-maktx ',' into lw_ftp-maktx.
concatenate lw_final-agency ',' into lw_ftp-agency.
append lw_ftp to lt_ftp.
x = x + 1.
clear: lw_ftp, lw_final .
endloop.
sort lt_final[] descending by budat.
endif.
endform. " fr_final_output_data
&----
*& Form display_data
&----
form fr_display_data using lt_final type tt_final .
data: lt_fieldcat type slis_t_fieldcat_alv.
gf_repid = sy-repid.
perform e01_fieldcat_init changing lt_fieldcat[].
perform eventtab_build changing gt_events.
perform e04_comment_build using gt_list_top_of_page[].
perform display_report using lt_final
lt_fieldcat.
endform. " display_data
&----
*& Form e01_fieldcat_init
&----
form e01_fieldcat_init changing lt_fieldcat type slis_t_fieldcat_alv.
data: ls_fieldcat type slis_fieldcat_alv,
ls_sort type slis_sortinfo_alv. "#EC *
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-ref_fieldname = 'MATNR'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'EKPO'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '1'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MAKTX'.
ls_fieldcat-ref_fieldname = 'MAKTX'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'MAKT'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '2'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'SERNR'.
ls_fieldcat-ref_fieldname = 'SERNR'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'OBJK'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '3'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'BUDAT'.
ls_fieldcat-ref_fieldname = 'BUDAT'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'MKPF'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '4'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'EBELN'.
ls_fieldcat-ref_fieldname = 'EBELN'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'EKPO'.
ls_fieldcat-key = ' '.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '5'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-ref_fieldname = 'WERKS'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'MSEG'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '6'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'LGORT'.
ls_fieldcat-ref_fieldname = 'LGORT'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'MSEG'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '7'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'NAME1'.
ls_fieldcat-ref_fieldname = 'NAME1'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'T001W'.
ls_fieldcat-seltext_l = 'Plant Desc'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '8'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'AGENCY'.
ls_fieldcat-ref_fieldname = 'AGENCY'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'ZCRMTOSAP'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '9'.
ls_fieldcat-seltext_l = 'Dealer code'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MBLNR'.
ls_fieldcat-ref_fieldname = 'MBLNR'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'MSEG'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '10'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'BWART'.
ls_fieldcat-ref_fieldname = 'BWART'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'MSEG'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '11'.
ls_fieldcat-seltext_l = 'Movement Type'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'BWTAR'.
ls_fieldcat-ref_fieldname = 'BWTAR'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'MSEG'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '12'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'PS_PSP_PNR'.
ls_fieldcat-ref_fieldname = 'PS_PSP_PNR'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-ref_tabname = 'MSEG'.
ls_fieldcat-no_out = ' '.
ls_fieldcat-col_pos = '13'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'COUNT'.
ls_fieldcat-tabname = 'LT_FINAL'.
ls_fieldcat-do_sum = 'X'.
append ls_fieldcat to lt_fieldcat.
clear ls_sort.
ls_sort-fieldname = 'LGORT'.
ls_sort-tabname = 'LT_FINAL'.
ls_sort-subtot = 'X'.
append ls_sort to gt_sort.
endform. "E01_FIELDCAT_INIT
&----
*& Form e04_comment_build
&----
form e04_comment_build using e04_lt_top_of_page type slis_t_listheader.
data : v_time(10) type c, "#EC *
ls_line type slis_listheader,
v_text(50) type c,
v_date_low(10) type c,
v_date_high(10) type c.
write s_budat-low to v_date_low.
write s_budat-high to v_date_high.
if v_date_low = '00.00.0000'.
v_date_low = '01.01.0000'.
endif.
if v_date_high = '00.00.0000'.
v_date_high = '31.12.9999'.
endif.
if s_eqtyp = 'IEQC' or s_eqtyp = 'IEQD'.
concatenate 'RCV Stocks between' v_date_low 'and' v_date_high
into v_text separated by space.
elseif s_eqtyp = 'IEQE' or s_eqtyp = 'IEQF'.
concatenate 'ESN Stocks between' v_date_low 'and' v_date_high
into v_text separated by space.
else.
concatenate 'Stocks between' v_date_low 'and' v_date_high
into v_text separated by space.
endif.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = v_text.
append ls_line to e04_lt_top_of_page.
endform. " e04_comment_build
----
FORM TOP_OF_PAGE *
----
........ *
----
form top_of_page. "#EC CALLED
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = gt_list_top_of_page.
endform . "TOP_OF_PAGE
&----
*& Form display_report
&----
form display_report using lt_final type tt_final
lt_fieldcat type slis_t_fieldcat_alv.
data: lw_fieldcatalog type slis_fieldcat_alv,
lf_tabix type sy-tabix.
loop at lt_fieldcat into lw_fieldcatalog.
lf_tabix = sy-tabix.
if lw_fieldcatalog-fieldname = 'LGORT'.
lw_fieldcatalog-do_sum = 'X'.
X_fieldcatalog-CHECKBOX = 'X'.
X_FIELDCATALOG-INPUT = 'X'.
endif.
modify lt_fieldcat from lw_fieldcatalog index lf_tabix.
endloop.
POPULATE LAYOUT STRUCTURE
gs_layout-subtotals_text = 'TOTAL'.
gs_layout-totals_text = 'GRAND TOTAL'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_background_id = 'ALV_BACKGROUND'
i_callback_program = gf_repid
i_callback_pf_status_set = 'PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'ITAB_FINAL'
is_layout = gs_layout
it_fieldcat = lt_fieldcat[]
it_special_groups = gt_sp_group[]
it_sort = gt_sort[]
it_filter = gt_filter[]
i_save = gf_save
is_variant = gf_variant
it_events = gt_events[]
is_print = gs_print
it_alv_graphics = gt_alv_graphics[]
it_excluding = gt_excluding
tables
t_outtab = lt_final.
endform. " display_report
&----
*& Form USER_COMMAND
&----
form user_command using g_ucomm type sy-ucomm
g_field type slis_selfield. "#EC *
case g_ucomm.
when '&IC1'.
message e009(zmmabap).
endcase.
endform. "USER_COMMAND
&----
*& Form eventtab_build
&----
form eventtab_build changing lt_events type slis_t_event.
constants:
gc_formname_top_of_page type slis_formname value 'TOP_OF_PAGE'.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = lt_events.
read table lt_events with key name = slis_ev_top_of_page
into ls_event.
if sy-subrc = 0.
move gc_formname_top_of_page to ls_event-form.
append ls_event to lt_events.
endif.
endform. "eventtab_build
&----
*& Form ftp_data
&----
text
----
form ftp_data using lt_ftp type tt_ftp.
data: e_file type rlgrap-filename, "#EC *
duser(64) TYPE c VALUE 'biftp',
dpwd(64) TYPE c VALUE 'biftp',
dhost(64) TYPE c VALUE '172.17.7.70',
dfile(256) type c, " VALUE 'FWP_Stocks.txt',
dest type rfcdes-rfcdest value 'SAPFTP'.
concatenate 'FWP_Data_' s_budat-low '_' s_budat-high '.txt' into dfile.
data: dhdl type i,
blob_length type i,
mi_key type i value 26101957,
mi_pwd_len type i,
mi_handle type i, "#EC *
lf_fnam_sour type gf_fnam_sour,
lf_p_mail type gf_p_mail,
lf_msg type gf_msg,
lf_command type gf_command.
*download the file..
IF IT_FTP[] IS NOT INITIAL.
call 'AB_RFC_X_SCRAMBLE_STRING'
id 'SOURCE' field dpwd id 'KEY' field mi_key
id 'SCR' field 'X' id 'DESTINATION' field dpwd
id 'DSTLEN' field mi_pwd_len.
call function 'FTP_CONNECT'
exporting
user = duser
password = dpwd
host = dhost
rfc_destination = dest
importing
handle = dhdl.
blob_length = x * 208.
call function 'FTP_R3_TO_SERVER'
exporting
handle = dhdl
fname = dfile
blob_length = blob_length
character_mode = ' '
tables
blob = lt_ftp
exceptions
tcpip_error = 1
command_error = 2
data_error = 3
others = 4.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
lf_fnam_sour = x.
lf_p_mail = 'Tarun.Mohapatra@tatatel.co.in'.
concatenate text-013 lf_fnam_sour lf_msg into lf_msg separated by space.
concatenate 'echo "' lf_msg '" | mailx -s "SAP feed file is placed on ftp"'
into lf_command.
concatenate lf_command lf_p_mail into lf_command separated by space.
condense lf_command.
perform uxcmd using lf_command.
write : 'FTP DONE ) !!! '.
ENDIF.
Disconnect
call function 'FTP_DISCONNECT'
exporting
handle = dhdl.
endif.
clear : lf_fnam_sour ,
lf_p_mail ,
lf_msg ,
lf_command .
endform. " ftp_data
&----
*& Form uxcmd
&----
form uxcmd using p_command. "#EC *
"issue UNIX wa_command by calling system function.
data: begin of itab occurs 0, "#EC *
line(255),
end of itab.
call 'SYSTEM' id 'COMMAND' field p_command
id 'TAB' field itab-sys.
endform. " uxcmd
&----
*& Form fr_display_no_data
&----
form fr_display_no_data .
skip 1.
write: /2 'No relevant data Exists for the following Selection.'.
endform. " fr_display_no_data
----
<b>
****************************************
include zmmr_stockdetails_variables .
***************************************</b>
----
TYPE POOLS
----
type-pools: slis.
----
STRUCTURES
----
types: begin of tw_doc, "MSEG
mblnr type mblnr,
mjahr type mjahr,
zeile type mblpo,
bwart type bwart,
matnr type matnr,
werks type werks_d,
lgort type lgort_d,
shkzg type shkzg,
bwtar type bwtar_d,
ebeln type bstnr,
ps_psp_pnr type ps_psp_pnr,
budat type budat,
equnr type equnr,
----------------------------
sernr type gernr,
obknr type objknr,
----------------------------
datum type datum,
uzeit type uzeit,
----------------------------
name1 type name1,
maktx type maktx,
agency type sgtxt,
end of tw_doc,
tt_doc type standard table of tw_doc,
begin of tw_doc_temp, "MSEG
mblnr type mblnr,
mjahr type mjahr,
sernr type gernr,
bwart type bwart,
datum type datum,
uzeit type uzeit,
werk type werks_d,
plant type lgort_d,
end of tw_doc_temp,
tt_doc_temp type standard table of tw_doc_temp,
begin of tw_ser03, "SER03
obknr type objknr,
mblnr type mblnr,
mjahr type mjahr,
zeile type mblpo,
bwart type bwart,
datum type datum,
uzeit type uzeit,
anzsn type anzsn,
werk type werks_d,
lagerort type lgort_d,
end of tw_ser03,
tt_ser03 type standard table of tw_ser03,
begin of tw_objk , "OBJK
obknr type objknr,
equnr type equnr,
sernr type gernr,
matnr type matnr,
end of tw_objk,
tt_objk type standard table of tw_objk,
begin of tw_equi, "EQUI
equnr type equnr,
end of tw_equi,
tt_equi type standard table of tw_equi,
begin of tw_final ,
equnr type equnr, "-------change
matnr type matnr,
mjahr type mjahr,
maktx type maktx,
sernr type gernr,
budat type budat,
uzeit type uzeit,
ebeln type bstnr,
werks type werks_d,
name1 type name1,
lgort type lgort_d,
shkzg type shkzg,
agency type sgtxt,
mblnr type mblnr,
zeile type mblpo,
obknr type objknr,
bwart type bwart,
bwtar type bwtar_d,
ps_psp_pnr type ps_psp_pnr,
count type i,
end of tw_final,
tt_final type standard table of tw_final,
begin of tw_ftp ,
matnr(19) type c,
maktx(41) type c,
sernr(19) type c,
budat(9) type c,
ebeln(11) type c,
werks(5) type c,
name1(31) type c,
lgort(5) type c,
agency(21) type c,
mblnr(11) type c,
bwart(4) type c,
bwtar(11) type c,
ps_psp_pnr(19) type c,
pclineend(2) TYPE x value '0D0A',
end of tw_ftp,
tt_ftp type standard table of tw_ftp,
gf_fnam_sour(255),
gf_msg(200),
gf_p_mail(128),
gf_command(255) type c.
*----
CONSTANTS
*----
constants:
c_101 type mseg-bwart value '101',
c_102 type mseg-bwart value '102',
c_311 type mseg-bwart value '311',
c_312 type mseg-bwart value '312',
c_shkzg_s type mseg-shkzg value 'S',
c_shkzg_h type mseg-shkzg value 'H',
gc_formname_top_of_page type slis_formname value 'TOP_OF_PAGE'."#EC *
*----
AlV related data declarations
*----
data: gt_fieldcat type slis_t_fieldcat_alv,
gs_layout type slis_layout_alv ,
gs_print type slis_print_alv,
gs_sort type slis_sortinfo_alv,
gt_sort type slis_t_sortinfo_alv ,
gt_filter type slis_t_filter_alv,
gt_sp_group type slis_t_sp_group_alv,
gt_alv_graphics type dtc_t_tc,
gt_excluding type slis_t_extab ,
gt_events type slis_t_event ,
gf_repid type sy-repid,
gt_list_top_of_page type slis_t_listheader,
gf_boxnam type slis_fieldname value 'BOX', "#EC *
p_f2code type sy-ucomm value '&ETA', "#EC *
p_lignam type slis_fieldname value 'LIGHTS', "#EC *
gf_save(1) type c,
gf_default(1) type c, "#EC *
gf_exit(1) type c, "#EC *
x(9) type c, "#EC *
gx_variant type disvariant, "#EC *
gf_variant type disvariant,
gf_mblnr type mblnr,
gf_mjahr type mjahr,
gf_ebeln type bstnr,
gf_cpudt type cpudt,
---for 'select-options'--
gf_matnr type mara-matnr,
gf_lgort type mseg-lgort,
gf_budat type bkpf-budat,
gf_eqtyp type equi-eqtyp,
gf_bwart type mseg-bwart,
gf_sobkz type mseg-sobkz,
gf_bwtar type mseg-bwtar,
Global Variables for menu
gf_user_command(30) value 'USER_COMMAND', "#EC *
gf_status_set(30) value 'PF_STATUS_SET'. "#EC *
----
*----
Parameter / Selection - screens
*----
selection-screen begin of block main with frame title text_001.
selection-screen skip.
select-options s_matnr for gf_matnr. "Material Number
parameters p_werks type mseg-werks obligatory. "Plant
select-options s_lgort for gf_lgort . "Storage Location
select-options s_budat for gf_budat. "Posting Date
select-options s_eqtyp for gf_eqtyp. "Equipment type
select-options s_bwart for gf_bwart. "Movement type
select-options s_sobkz for gf_sobkz. "Special stock indicator
select-options s_bwtar for gf_bwtar. "Batch
selection-screen skip.
selection-screen end of block main.
selection-screen begin of block loc with frame title text_002.
parameters p_list radiobutton group r1.
parameters p_ftp radiobutton group r1.
selection-screen end of block loc.
selection-screen: begin of block upld1 with frame title text-004.
parameters: duser(20) lower case.
selection-screen begin of line.
selection-screen comment 1(31) text-003 for field dpwd.
parameters: dpwd(64) modif id sc1 lower case.
selection-screen end of line.
parameters: dhost(20) type c.
select-options s_cpudt for gf_cpudt. "005
selection-screen: end of block upld1.
*----
INITIALIZATION EVENT
*----
initialization.
text_001 = 'Basic Selection Criteria'.
&----
*& A T S E L E C T I O N S C R E E N E V E N T S *
&----
Validation of Material number
at selection-screen on s_matnr.
perform fr_validate_matnr.
Validation of Storage Location
at selection-screen on s_lgort.
perform fr_validate_lgort.
Validation of Equipment category
at selection-screen on s_eqtyp.
perform fr_validate_eqtyp.
Validation of Movement Type
at selection-screen on s_bwart.
perform fr_validate_bwart.
Valiation of Special Stock Indicator
at selection-screen on s_sobkz.
perform fr_validate_sobkz.
*Validation of Valuation Type
at selection-screen on s_bwtar.
perform fr_validate_bwtar.
*----
**AT SELECTION-SCREEN OUTPUT
*----
at selection-screen output.
loop at screen.
if screen-group1 = 'SC1'.
screen-intensified = '1'.
screen-active = '1'.
screen-output = '1'.
screen-input = '1'.
screen-invisible = '1'.
modify screen.
continue.
endif.
endloop.
*----
at selection-screen.
*----
Validation of Plant
perform fr_validate_werks.
&----
*& Form FR_VALIDATE_MATNR
&----
form fr_validate_matnr .
data : lf_matnr type matnr.
if ( s_matnr is not initial ).
select single matnr
from mara
into lf_matnr
where matnr in s_matnr.
if sy-subrc <> 0.
message e000.
endif.
clear lf_matnr.
endif.
endform. " FR_VALIDATE_MATNR
&----
*& Form fr_validate_werks
&----
form fr_validate_werks .
data : lf_werks type werks_d.
if ( p_werks is not initial ).
select single werks
from t001w
into lf_werks
where werks = p_werks.
if sy-subrc <> 0.
message e001.
endif.
clear lf_werks.
endif.
endform. " fr_validate_werks
&----
*& Form fr_validate_lgort
&----
form fr_validate_lgort.
data lf_lgort type lgort_d.
if ( s_lgort is not initial ).
select single lgort
from t001l
into lf_lgort
where lgort in s_lgort.
if sy-subrc <> 0.
message e002.
endif.
clear lf_lgort.
endif.
endform. " fr_validate_lgort
&----
*& Form fr_validate_eqtyp
&----
form fr_validate_eqtyp.
data lf_eqtyp type eqtyp.
if ( s_eqtyp is not initial ).
select single eqtyp
from t370t
into lf_eqtyp
where eqtyp in s_eqtyp.
if sy-subrc <> 0.
message e003.
endif.
clear lf_eqtyp.
endif.
endform. " fr_validate_eqtyp
&----
*& Form fr_validate_bwart
&----
form fr_validate_bwart .
data lf_bwart type bwart.
if ( s_bwart is not initial ).
select single bwart
from t156
into lf_bwart
where bwart in s_bwart.
if sy-subrc <> 0.
message e004.
endif.
clear lf_bwart.
endif.
endform. " fr_validate_bwart
&----
*& Form fr_validate_sobkz
&----
form fr_validate_sobkz .
data lf_sobkz type sobkz.
if ( s_sobkz is not initial ).
select single sobkz
from t148
into lf_sobkz
where sobkz in s_sobkz.
if sy-subrc <> 0.
message e005.
endif.
clear lf_sobkz.
endif.
endform. " fr_validate_sobkz
&----
*& Form fr_validate_bwtar
&----
form fr_validate_bwtar .
data lf_bwtar type bwtar_d.
if ( s_bwtar is not initial ).
select single bwtar
from t149d
into lf_bwtar
where bwtar in s_bwtar.
if sy-subrc <> 0.
message e006.
endif.
clear lf_bwtar.
endif.
endform. " fr_validate_bwtar .
*******************************************
could any one check this??
already i sent the details in above mails..
thanking you.,
ramu
‎2006 Aug 21 10:59 AM
plssssssssss...
help me in this senario..
i have sent the details and code i have written ..
could any one pls check it out..
thanks
Ramakrishna S
‎2006 Aug 21 5:36 PM