02-26-2015 4:08 PM
Hi Experts,
I have generated a simple ALV report that I will be using in an enhancement. I'm currently using select statements to get the data I need but, due to coding standards, I have to use read table. I am a new ABAP programmer so I'm struggling a little bit. What changes do I need to make to achieve the same effect?
Thank you,
Jim
TABLES: t001w, t499s. "tables
data: BEGIN OF it_alv OCCURS 10, "data declaration for internal table
mandt like t001w-mandt,
name1 like t001w-name1,
werks like t001w-werks,
kunnr like t001w-kunnr,
ktext like t499s-ktext,
end of it_alv.
type-pools: slis.
data: afield type slis_fieldcat_alv, "default sap data declaration
fieldcat type slis_t_fieldcat_alv,
fieldlayout TYPE slis_layout_alv.
fieldlayout-colwidth_optimize = 'X'. "optional optimize width of columns
clear afield.
*Name columns section
*--------------------------------------------------
"afield-col_pos = 1 .
afield-fieldname = 'MANDT'.
afield-seltext_m = 'Client'.
append afield to fieldcat.
"afield-col_pos = 2 .
afield-fieldname = 'NAME1'.
afield-seltext_m = 'Plant Desc'.
append afield to fieldcat.
*afield-col_pos = 3 .
*afield-fieldname = 'WERKS'.
*afield-seltext_m = 'Plant'.
*append afield to fieldcat.
*
*afield-col_pos = 4 .
*afield-fieldname = 'KUNNR'.
*afield-seltext_m = 'Cust # of Plant'.
*append afield to fieldcat.
"afield-col_pos = 3 .
afield-fieldname = 'KTEXT'.
afield-seltext_m = 'Location Desc'.
append afield to fieldcat.
*------------------------------------------------------------------
*START-OF-SELECTION.
*READ TABLE ATTEMPT
*Select data from tables and append the internal table
SELECT * from t001w.
SELECT * from t499s where werks eq t001w-werks. "edit this select to match implementation parameters
it_alv-mandt = t001w-mandt.
it_alv-name1 = t001w-name1.
it_alv-werks = t001w-werks.
it_alv-kunnr = t001w-kunnr.
it_alv-ktext = t499s-ktext.
append it_alv.
endselect.
ENDSELECT.
*----------------------------------------------------------------*
*---------------------END IMPLEMENTATION-------------------------*
*----------------------------------------------------------------*
*produce the alv table using the settings below. This section is not needed for the actual implementation since it is already included in the default
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_grid_title = 'Test'
it_fieldcat = fieldcat
is_layout = fieldlayout
tables
t_outtab = it_alv.
03-01-2015 9:42 PM
I did not get your requirement here , Why you are creating report which you will use in Enhancement . Please understand the use of the Enhancement First and Report . Both are for different purpose .
Regarding READ and SELECT also solve different requirement .
SELECT always use to retrieve the data from the DATABASE where READ is used in PROGRAM to OPTIMISE/MODIFY the data as and when required based on the requirement.
03-02-2015 6:50 AM
03-02-2015 1:54 PM
I have to add Name1-t001w and ktext-t499s to the standard IW38 form. I figured all I would have to do is write a select statement and append the relevant fields (object_tab for example) as I would if I were making a stand alone alv. Is this wrong?
Thanks
03-02-2015 5:43 PM
Also, shouldn't this work?
This part of the code isn't even activated.