2009 Apr 06 6:42 AM
In selection screen I am having 3 input parameters customer account no.(mseg-kunnr) date (system date) time(system time)..and in output sections I have to get the list on the basis of these inputs
1.S.No.
2.Material Number(mseg-matnr)
3.Material descriptiopn(makt-maktx)
4.Material quantity.(mseg-menge)
I have coded upto this ..can u pls suggest to go further to get the desired output..
REPORT ZGATE1.
Tables:kna1,mseg,makt.
parameters: p_cust type kna1-kunnr.
TYPES: BEGIN OF TY_GPASS,
matnr type mseg-matnr,
maktx type makt-maktx,
qty type mseg-menge,
END OF TY_GPASS.
data: it_gpass type table of ty_gpass,
wa_gpass like line of it_gpass.
TYPES: BEGIN OF TY_matnr,
matnr type mseg-matnr,
kunnr type mseg-kunnr,
END OF TY_matnr.
data: it_matnr type table of ty_matnr,
wa_matnr like line of it_matnr.
TYPES: BEGIN OF TY_makt,
matnr type mseg-matnr,
maktx type makt-maktx,
END OF TY_makt.
data: it_makt type table of ty_makt,
wa_makt like line of it_makt.
TYPES: BEGIN OF TY_qty,
matnr type mseg-matnr,
menge type mseg-menge,
END OF TY_qty.
data: it_qty type table of ty_qty,
wa_qty like line of it_qty.
types: begin of ty_header,
accno type kunnr,
date type sy-datum,
time type sy-uzeit,
end of ty_header.
data: wa_header type ty_header.
wa_header-accno = p_cust.
wa_header-date = sy-datum.
wa_header-time = sy-uzeit.
*Item data retireval
select matnr kunnr from mseg into table it_matnr where kunnr = p_cust.
select matnr maktx from makt into table it_makt for all entries in it_matnr where matnr = it_matnr-matnr.
select matnr menge from mseg into table it_qty for all entries in it_matnr where matnr = it_matnr-matnr.
loop at it_matnr into w_matnr .
read table it_makt into w_makt where w_makt-matnr=w_matnr-matnr.
Regards,
Sambaran
In selection screen I am having 3 input parameters customer account no.(mseg-kunnr) date (system date) time(system time)..and in output sections I have to get the list on the basis of these inputs
1.S.No.
2.Material Number(mseg-matnr)
3.Material descriptiopn(makt-maktx)
4.Material quantity.(mseg-menge)
I have coded upto this ..can u pls suggest to go further to get the desired output..
REPORT ZGATE1.
Tables:kna1,mseg,makt.
parameters: p_cust type kna1-kunnr.
TYPES: BEGIN OF TY_GPASS,
matnr type mseg-matnr,
maktx type makt-maktx,
qty type mseg-menge,
END OF TY_GPASS.
data: it_gpass type table of ty_gpass,
wa_gpass like line of it_gpass.
TYPES: BEGIN OF TY_matnr,
matnr type mseg-matnr,
kunnr type mseg-kunnr,
END OF TY_matnr.
data: it_matnr type table of ty_matnr,
wa_matnr like line of it_matnr.
TYPES: BEGIN OF TY_makt,
matnr type mseg-matnr,
maktx type makt-maktx,
END OF TY_makt.
data: it_makt type table of ty_makt,
wa_makt like line of it_makt.
TYPES: BEGIN OF TY_qty,
matnr type mseg-matnr,
menge type mseg-menge,
END OF TY_qty.
data: it_qty type table of ty_qty,
wa_qty like line of it_qty.
types: begin of ty_header,
accno type kunnr,
date type sy-datum,
time type sy-uzeit,
end of ty_header.
data: wa_header type ty_header.
wa_header-accno = p_cust.
wa_header-date = sy-datum.
wa_header-time = sy-uzeit.
*Item data retireval
select matnr kunnr from mseg into table it_matnr where kunnr = p_cust.
select matnr maktx from makt into table it_makt for all entries in it_matnr where matnr = it_matnr-matnr.
select matnr menge from mseg into table it_qty for all entries in it_matnr where matnr = it_matnr-matnr.
loop at it_matnr into w_matnr .
read table it_makt into w_makt where w_makt-matnr=w_matnr-matnr.
Regards,
Sambaran
2009 Apr 06 6:50 AM
Hi:
1.As per performanance basis, i would not advice to use of Line of to declare the work area , instead of it, you can use it as
data: wa_gpass typeiyt_gpass.
2.
if not p_cust is initial.
select matnr kunnr from mseg into table it_matnr where kunnr = p_cust.
endif.
if not it_matnr[] is initial.
select matnr maktx from makt into table it_makt for all entries in it_matnr where matnr = it_matnr-matnr.
select matnr menge from mseg into table it_qty for all entries in it_matnr where matnr = it_matnr-matnr.
endif..
3. before loop , search the intenal table and then use read table by using binary search
like read table it_makt into w_makt where w_makt-matnr=w_matnr-matnr binary search.
Regards
Shashi
2009 Apr 06 6:56 AM
modify the following into :
select matnr kunnr from mseg into table it_matnr where kunnr = p_cust.
select matnr maktx from makt into table it_makt for all entries in it_matnr where matnr = it_matnr-matnr.
select matnr menge from mseg into table it_qty for all entries in it_matnr where matnr = it_matnr-matnr.
into
select matnr menge kunnr from mseg into table it_matnr where kunnr = p_cust.
select matnr maktx from makt into table it_makt for all entries in it_matnr where matnr = it_matnr-matnr.
Now build the final internal table
data : begin of it_display occurs 0,
no type i,
matnr type mseg-matnr,
maktx type makt-maktx,
menge type mseg-menge,
end of it_display.
loop at it_matnr.
move-correponding it_matnr to it_display.
read table it_makt with key matnr = it_matnr-matnr.
it_display-maktx = it_makt-maktx.
append it_display.
enloop.
Then you can
loop at it_Display.
write : it_display-no, it_display-matnr, it_display-maktx, it_display-menge.
endloop.
2009 Apr 06 6:57 AM
Linked to the 3rd point of Shashi, I can add/ suggest that before entering into
loop you sort the internal table with the fields that you use to the where clause of
'READ TABLE' table statement.
Edited by: Sarbajit Majumdar on Apr 6, 2009 11:28 AM
Edited by: Sarbajit Majumdar on Apr 6, 2009 11:29 AM
2009 Apr 06 7:10 AM
Hi ,
use like this.
Build a final int. table and bulid work area for all tables.
types : begin of ls_display ,
no type i,
matnr type mseg-matnr,
maktx type makt-maktx,
menge type mseg-menge,
end of ls_display.
data : lt_display type table of ls_display ,
wa_display type ls_display.
if not p_cust is initial.
select matnr menge kunnr from mseg into table it_matnr where kunnr = p_cust.
if not it_matnr[] is initial.
select matnr maktx from makt into table it_makt for all entries in it_matnr where matnr = it_matnr-matnr.
endif.
endif.
loop at it_matnr into wa_matnr.
move-correponding wa_matnr to wa_display.
read table it_makt into wa_makt with key matnr = wa_matnr-matnr.
wa_display-maktx = wa_makt-maktx.
append it_display from wa_display.
enloop.
This will give u performaence and new syntex.
Regards