‎2005 Dec 08 3:25 PM
Hi to all,
Please go through the following programe......
i want to add the new fields <b>BEDAT</b> from <b>EKKO</b> and <b>LABST</b> from <b>MARD</b> to this report....
please suggest me how to do.....???
TABLES: MARD, /UPM/GTB10 , EKKO, /UPM/GTB11.
TYPES : KILOMETER(10) TYPE C, "INT4 (LENGTH 10)
STANDARDPREIS(11) TYPE C, "CURR (LENGTH 11)
PSTNG_DATE(08) TYPE C, "DATS (LENGTH 08)
QUANTITY(13) TYPE C, "QUAN (LENGTH 13)
VCOLOR(02) TYPE C.
DATA: BEGIN OF ITAB1 OCCURS 0,
MATNR like MARD-MATNR,
<b>LABST like MARD-LABST,</b>
END OF ITAB1.
DATA: BEGIN OF ITAB2 OCCURS 0,
MATNR LIKE /UPM/GTB10-MATNR,
EXTMATLGRP LIKE /UPM/GTB10-EXTMATLGRP,
LAGERORT LIKE /UPM/GTB10-LAGERORT,
LAGERPLATZ LIKE /UPM/GTB10-LAGERPLATZ,
BESCHREIBUNG LIKE /UPM/GTB10-BESCHREIBUNG,
VCOLOR LIKE /UPM/GTB10-VCOLOR,
VIN LIKE /UPM/GTB10-VIN,
ENOTIZ LIKE /UPM/GTB10-ENOTIZ,
STANDARDPREIS LIKE /UPM/GTB11-NETPR, "CURR (LENGTH 1)
HERSTELLER LIKE /UPM/GTB10-HERSTELLER,
KILOMETER LIKE /UPM/GTB10-KILOMETER, "INT4 (LENGTH 10)
<b> BEDAT LIKE EKKO-BEDAT,</b> "DATS (LENGTH 08)
END OF ITAB2.
DATA: BEGIN OF ITAB3 OCCURS 0,
MATNR LIKE /UPM/GTB10-MATNR,
EXTMATLGRP LIKE /UPM/GTB10-EXTMATLGRP,
LAGERORT LIKE /UPM/GTB10-LAGERORT,
LAGERPLATZ LIKE /UPM/GTB10-LAGERPLATZ,
BESCHREIBUNG LIKE /UPM/GTB10-BESCHREIBUNG,
VCOLOR(02) TYPE C,
VIN LIKE /UPM/GTB10-VIN,
ENOTIZ LIKE /UPM/GTB10-ENOTIZ,
STANDARDPREIS(11) TYPE C,
HERSTELLER LIKE /UPM/GTB10-HERSTELLER,
KILOMETER(10) TYPE C,
PSTNG_DATE(08) TYPE C,
QUANTITY(13) TYPE C,
<b> LABST(13) TYPE C,</b> BEDAT(08) TYPE C,
BEDAT(08) TYPE C,
END OF ITAB3.
data: file type string.
*******************************SELECT OPTION*************************
PARAMETERS: P_FNAME LIKE rlgrap-filename
DEFAULT 'c:\temp\test.TXT' OBLIGATORY. " File Nameselect
**************************SELECT*************************************
at selection-screen on value-request for P_FNAME.
call function 'WS_FILENAME_GET'
exporting
DEF_FILENAME = ' '
def_path = P_FNAME
mask = ',.txt,.txt.'
mode = 'O'
TITLE = ' '
importing
filename = P_FNAME
RC =
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
START-OF-SELECTION.
select matnr labst from mard into table itab1 where labst gt 0.
check sy-subrc = 0.
sort itab1 ascending by matnr.
SELECT * FROM /UPM/GTB10 INTO CORRESPONDING FIELDS OF TABLE ITAB2
for all entries in ITAB1 WHERE MATNR = ITAB1-MATNR.
END-OF-SELECTION.
***********************OPEN DATASET***********************************
OPEN DATASET P_FNAME IN TEXT MODE ENCODING DEFAULT FOR OUTPUT.
check sy-subrc = 0.
loop at itab2.
move-corresponding itab2 to itab3.
*move itab1-labst to itab3-labst.
transfer itab3 to P_FNAME.
append itab3.
endloop.
close dataset P_FNAME.
if sy-subrc = 0.
endif.
***********************************CALL FUNCTION GUI DOWNLOAD*********
file = p_fname.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = file
FILETYPE = 'ASC'
TABLES
DATA_TAB = ITAB3
EXCEPTIONS
others = 22.
IF SY-SUBRC <> 0.
ENDIF.
‎2005 Dec 08 3:32 PM
In
loop at itab2.
move-corresponding itab2 to itab3.
*move itab1-labst to itab3-labst.
transfer itab3 to P_FNAME.
append itab3.
endloop.
make the highlighted change.
loop at itab2.
move-corresponding itab2 to itab3.
<b>read table itab1 with key matnr = itab2-matnr.
if sy-subrc = 0.
move itab1-labst to itab3-labst.
endif.</b>
transfer itab3 to P_FNAME.
append itab3.
endloop.
‎2005 Dec 08 3:31 PM
Hi Raju,
Check the common fields in tables /UPM/GTB10 ,EKKO,MARD & make a join or select from those tables looping at the /UPM/GTB10 table.
‎2005 Dec 08 3:32 PM
In
loop at itab2.
move-corresponding itab2 to itab3.
*move itab1-labst to itab3-labst.
transfer itab3 to P_FNAME.
append itab3.
endloop.
make the highlighted change.
loop at itab2.
move-corresponding itab2 to itab3.
<b>read table itab1 with key matnr = itab2-matnr.
if sy-subrc = 0.
move itab1-labst to itab3-labst.
endif.</b>
transfer itab3 to P_FNAME.
append itab3.
endloop.
‎2005 Dec 08 3:37 PM
You added the fields to the internal table and you are selecting them from the database tables, so what problem are you encountering?
I don't know what this table /UPM/GTB10 is, so I cannot tell which field links this table with the EKKO table. You will have to figure it out, if that is your problem.
It is not a R/3(ERP) table. Is it some industry specific R/3?
Srinivas
‎2005 Dec 08 3:40 PM
Hi
MARD is the table with the storage location data, so you could have the same material in more storage location or plant than one: so don't you need plant and storage location?
Max