Dynamic field catalog
Hi all,
i have a strange problem,
in table WITH_ITEM the field ITT and wt_qbshh , we have different kinds of tax codes and tax amounts.
i was displaying these as two columns in my report.
but my client ask me to display the wt_qbshh field in different columns based on the witht value.
i mean lets say for example there are 2 types of tax codes 1 and 2 in witht.
and let my report will display lik this
tax amnt tax code
100.00 ; 1
150.00 ; 2
130.00 ; 1
120.00 ; 2
the client wants the report like this
tax amnt-type1 tax amnt-type 2
100.00
150.00
130.00 ;
120.00
is there any method for this kind of situation ?
currently i defined all kinds of tax types as fields in my internal tables also in fieldcatalog
and doing thie following
loop at tbl into temp.
case 'witht'.
when '1'.
temp-tax1 = temp-tax.
when '2'.
temp-tax2 = temp-tax.
endcase.
modify tbl from temp.
endloop.
i am asking for better way than this if exists
thanks in advance.
Hey check out this link
http://wiki.sdn.sap.com/wiki/display/ABAP/DYNAMICFIELDCATALOGINALV
May be you can modify your code lil bit.
Similar Messages
-
Reg: Dynamic Field catalog in ALV
Hi ,
Can any one guide me to build a dynamic field catalog in ALV report?
Below is the format which i expect..........
Material | Plant1 | Plant2 | Plant3 | ....................| Plant 20 |
Qty
Val
Qty
Val
Qty
Val
Qty
Val
The plant 1 to 20 has to be brought dynamically as headings from T001W table. (Horizontally populate)
Below each plant i need sub-headings "QTY" and "VAL". (Horizontally populate)
List of Materials should be brought vertically from MARA table. (Vertically populate)
Can anyone suggest how to bring out this format for populating data accordingly into the o/p format?
Ur help will be appreciated.
Thanks,
K.S.Kannanyour part of the code is present in routine
perform dynamic_table.
*& Report ZCS_NAC_MAT_CHARACTERISTICS
2/ Description ...: Business requirement is to get all materials
without any characteristic values maintained in SAP
which are given in the selection screen.
REPORT znac_material_char.
TYPE-POOLS : abap,
slis.
TABLES : kssk,
klah,
mara,
makt,
cabn,
t134,
t023.
DATA : i_fieldcat TYPE slis_t_fieldcat_alv ,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA : w_layout TYPE slis_layout_alv.
DATA : st_layout TYPE slis_layout_alv.
DATA : t_header TYPE slis_t_listheader,
w_header TYPE slis_listheader.
TYPES : BEGIN OF ty_cabn,
atinn TYPE cabn-atinn,
atnam TYPE cabn-atnam,
END OF ty_cabn.
DATA : i_cabn TYPE STANDARD TABLE OF ty_cabn WITH HEADER LINE.
DATA : w_cabn LIKE i_cabn.
TYPES : BEGIN OF ty_ausp,
objek TYPE ausp-objek,
atinn TYPE ausp-atinn,
klart TYPE ausp-klart,
END OF ty_ausp.
DATA : i_ausp TYPE STANDARD TABLE OF ty_ausp WITH HEADER LINE.
DATA : w_ausp LIKE i_ausp.
TYPES : BEGIN OF ty_mara,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
prdha TYPE mara-prdha,
mstae TYPE mara-mstae,
mstde TYPE mara-mstde,
END OF ty_mara.
DATA : i_mara TYPE STANDARD TABLE OF ty_mara WITH HEADER LINE.
DATA : w_mara LIKE i_mara.
DATA : i_mara_temp TYPE STANDARD TABLE OF ty_mara WITH HEADER LINE.
DATA : w_mara_temp LIKE i_mara_temp.
TYPES :BEGIN OF ty_data,
atnam TYPE cabn-atnam,
atinn TYPE cabn-atinn,
objek TYPE ausp-objek,
klart TYPE ausp-klart,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
prdha TYPE mara-prdha,
mstae TYPE mara-mstae,
mstde TYPE mara-mstde,
END OF ty_data.
DATA : i_data TYPE STANDARD TABLE OF ty_data WITH HEADER LINE.
DATA : w_data LIKE i_data.
DATA : i_class TYPE STANDARD TABLE OF sclass WITH HEADER LINE.
DATA : w_class LIKE i_class.
DATA : i_class_temp TYPE STANDARD TABLE OF sclass WITH HEADER LINE.
DATA : w_class_temp LIKE i_class_temp.
DATA : i_objdata TYPE STANDARD TABLE OF clobjdat WITH HEADER LINE.
DATA : w_objdata LIKE i_objdata.
TYPES : BEGIN OF ty_objdata_temp.
TYPES: matnr TYPE mara-matnr.
TYPES: maktx TYPE makt-maktx.
INCLUDE STRUCTURE clobjdat.
TYPES : prdha TYPE mara-prdha.
TYPES : mstde TYPE mara-mstde.
TYPES : END OF ty_objdata_temp.
DATA : i_objdata_temp TYPE STANDARD TABLE OF ty_objdata_temp WITH HEADER LINE.
DATA : w_objdata_temp LIKE i_objdata_temp.
FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
<fs_dyntable>,
<fs_fldval> TYPE ANY.
DATA: t_newtable TYPE REF TO data,
t_newline TYPE REF TO data,
fs_fldcat TYPE slis_t_fieldcat_alv,
t_fldcat1 TYPE lvc_t_fcat,
wa_it_fldcat TYPE lvc_s_fcat,
wa_colno(2) TYPE n,
wa_flname(30) TYPE c.
DATA: fieldname(20) TYPE c.
DATA: fieldvalue(40) TYPE c.
DATA: index(3) TYPE c,
v_time(60) TYPE c.
DATA: wa_cat LIKE LINE OF fs_fldcat.
CONSTANTS : c_nac TYPE klah-class VALUE 'NAC',
c_klart TYPE ausp-klart VALUE '001',
c_check TYPE c VALUE 'X' .
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (28) text-001 .
SELECT-OPTIONS: s_atnam FOR cabn-atnam NO INTERVALS OBLIGATORY. " Characteristic name
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1 .
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECT-OPTIONS: s_matnr FOR mara-matnr. " material Number
SELECT-OPTIONS: s_mtart FOR mara-mtart. " material type
SELECT-OPTIONS: s_matkl FOR mara-matkl. " material type
SELECT-OPTIONS: s_mstae FOR mara-mstae. " X-Plant material status
PARAMETERS : s_date LIKE sy-datum OBLIGATORY DEFAULT sy-datum . " date
SELECTION-SCREEN END OF BLOCK b2 .
AT SELECTION-SCREEN ON s_atnam.
SELECT SINGLE * FROM cabn WHERE atnam IN s_atnam.
IF sy-subrc 0.
MESSAGE text-003 TYPE 'E'.
ENDIF.
AT SELECTION-SCREEN ON s_matnr.
SELECT SINGLE * FROM mara WHERE matnr IN s_matnr.
IF sy-subrc 0.
MESSAGE text-004 TYPE 'E'.
ENDIF.
AT SELECTION-SCREEN ON s_mtart.
SELECT SINGLE * FROM t134 WHERE mtart IN s_mtart.
IF sy-subrc 0.
MESSAGE text-005 TYPE 'E'.
ENDIF.
AT SELECTION-SCREEN ON s_matkl.
SELECT SINGLE * FROM t023 WHERE matkl IN s_matkl.
IF sy-subrc 0.
MESSAGE text-006 TYPE 'E'.
ENDIF.
START-OF-SELECTION.
PERFORM get_data.
PERFORM get_data_keydate.
PERFORM material_all_charname.
PERFORM get_classification.
PERFORM dynamic_table.
*& Form dynamic_table
text
--> p1 text
<-- p2 text
FORM dynamic_table.
PERFORM fieldcatalog.
PERFORM dynamic_table_create.
PERFORM final_data.
PERFORM final_fieldcatalog.
PERFORM layout_build.
PERFORM grid_display.
ENDFORM. " fieldcat
*& Form layout_build
text
FORM layout_build .
st_layout-zebra = c_check.
st_layout-no_vline = ''.
st_layout-colwidth_optimize = c_check.
st_layout-detail_popup = c_check.
st_layout-detail_initial_lines = c_check.
st_layout-detail_titlebar = text-021.
ENDFORM. " layout_build
*& Form alv_top_of_page
text
FORM alv_top_of_page.
REFRESH t_header.
CLEAR t_header.
w_header-typ = 'H'. "H=Header, S=Selection, A=Action
w_header-key = ' '.
w_header-info = text-019.
APPEND w_header TO t_header.
CONCATENATE sy-datum4(2) '-' sy-datum6(2) '-' sy-datum0(4) ' / ' sy-uzeit0(2) ':' sy-uzeit2(2) ':' sy-uzeit4(2) INTO v_time.
w_header-typ = 'S'. "H=Header, S=Selection, A=Action
w_header-key = text-020.
w_header-info = v_time.
APPEND w_header TO t_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM. "alv_top_of_page
*& Form grid_display
text
--> p1 text
<-- p2 text
FORM grid_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = 'ALV_TOP_OF_PAGE'
it_fieldcat = fs_fldcat
is_layout = st_layout
i_default = c_check
i_save = 'A'
it_events = v_events[]
TABLES
t_outtab = <t_dyntable>.
ENDFORM. " grid_display
*& Form FINAL_FIELDCATALOG
text
--> p1 text
<-- p2 text
FORM final_fieldcatalog .
wa_cat-fieldname = text-009.
wa_cat-seltext_m = text-015.
wa_cat-outputlen = 18.
APPEND wa_cat TO fs_fldcat.
wa_cat-fieldname = text-011.
wa_cat-seltext_m = text-016.
wa_cat-outputlen = 40.
APPEND wa_cat TO fs_fldcat.
LOOP AT s_atnam.
CLEAR wa_cat.
wa_cat-fieldname = s_atnam-low.
wa_cat-seltext_m = s_atnam-low.
wa_cat-outputlen = '15'.
APPEND wa_cat TO fs_fldcat.
ENDLOOP.
wa_cat-fieldname = text-012.
wa_cat-seltext_m = text-017.
wa_cat-outputlen = 18.
APPEND wa_cat TO fs_fldcat.
wa_cat-fieldname = text-013.
wa_cat-seltext_m = text-018.
wa_cat-outputlen = 8.
APPEND wa_cat TO fs_fldcat.
ENDFORM. " FINAL_FIELDCATALOG
*& Form FIELDCATALOG
text
--> p1 text
<-- p2 text
FORM fieldcatalog .
wa_it_fldcat-fieldname = text-009.
wa_it_fldcat-datatype = text-010.
wa_it_fldcat-intlen = 18.
APPEND wa_it_fldcat TO t_fldcat1.
wa_it_fldcat-fieldname = text-011.
wa_it_fldcat-datatype = text-010.
wa_it_fldcat-intlen = 40.
APPEND wa_it_fldcat TO t_fldcat1.
LOOP AT s_atnam.
CLEAR wa_it_fldcat.
wa_it_fldcat-fieldname = s_atnam-low.
wa_it_fldcat-datatype = text-010.
wa_it_fldcat-intlen = 30.
APPEND wa_it_fldcat TO t_fldcat1.
ENDLOOP.
wa_it_fldcat-fieldname = text-012.
wa_it_fldcat-datatype = text-010.
wa_it_fldcat-intlen = 18.
APPEND wa_it_fldcat TO t_fldcat1.
wa_it_fldcat-fieldname = text-013.
wa_it_fldcat-datatype = text-014.
wa_it_fldcat-intlen = 8.
APPEND wa_it_fldcat TO t_fldcat1.
ENDFORM. " FIELDCATALOG
*& Form DYNAMIC_TABLE_CREATE
text
--> p1 text
<-- p2 text
FORM dynamic_table_create .
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fldcat1
IMPORTING
ep_table = t_newtable.
ASSIGN t_newtable->* TO <t_dyntable>.
Create dynamic work area and assign to FS
CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
ASSIGN t_newline->* TO <fs_dyntable>.
ENDFORM. " DYNAMIC_TABLE_CREATE
*& Form FINAL_DATA
text
--> p1 text
<-- p2 text
FORM final_data .
LOOP AT i_objdata_temp INTO w_objdata_temp.
*assign w_objdata_temp-matnr to <fs_dyntable>.
AT NEW matnr.
wa_flname = text-009.
fieldvalue = w_objdata_temp-matnr.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
ENDAT.
wa_flname = text-011.
fieldvalue = w_objdata_temp-maktx.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
wa_flname = w_objdata_temp-atnam.
fieldvalue = w_objdata_temp-ausp1.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
wa_flname = text-012.
fieldvalue = w_objdata_temp-prdha.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
wa_flname = text-013.
fieldvalue = w_objdata_temp-mstde.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
AT END OF matnr.
APPEND <fs_dyntable> TO <t_dyntable>.
ENDAT.
ENDLOOP.
ENDFORM. " FINAL_DATA
*& Form GET_CLASSIFICATION
text
--> p1 text
<-- p2 text
FORM get_classification .
LOOP AT i_data INTO w_data.
SELECT SINGLE * FROM klah WHERE class = c_nac.
IF sy-subrc = 0.
IF w_data-mstde >= klah-vondt.
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
class = c_nac
classtext = c_check
classtype = c_klart
clint = 0
features = c_check
language = sy-langu
object = w_data-objek
TABLES
t_class = i_class
t_objectdata = i_objdata
EXCEPTIONS
no_classification = 1
no_classtypes = 2
invalid_class_type = 3
OTHERS = 4.
LOOP AT i_class INTO w_class.
MOVE w_class TO w_class_temp.
APPEND w_class_temp TO i_class_temp.
ENDLOOP .
LOOP AT s_atnam.
READ TABLE i_objdata INTO w_objdata WITH KEY atnam = s_atnam-low.
IF sy-subrc = 0.
MOVE w_data-matnr TO w_objdata_temp-matnr.
MOVE w_data-maktx TO w_objdata_temp-maktx.
MOVE-CORRESPONDING w_objdata TO w_objdata_temp.
MOVE w_data-prdha TO w_objdata_temp-prdha.
MOVE w_data-mstde TO w_objdata_temp-mstde.
APPEND w_objdata_temp TO i_objdata_temp.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " GET_CLASSIFICATION -
ALV display using dynamic field catalog and dynamic internal table
hi ,
please guide me for ALV display using dynamic field catalog and dynamic internal table.
Thank you.Hi Rahul,
maybe thread dynamic program for alv is helpful for you. More information about the [SAP List Viewer (ALV)|http://help.sap.com/saphelp_nw70/helpdata/EN/5e/88d440e14f8431e10000000a1550b0/frameset.htm]. Also have a look into the example programs SALV_DEMO_TABLE*.
Regards Rudi -
Dynamic internal table and dynamic field catalog
hi
i need to decide the number of fields of the internal table at runtime
and then need to pass value to this internal table.
then i need to create the field catalog for this internal table (so here
field catalog is also dynamic) to display in alv.
how to achieve this dynamic internal table creation and dyanmic field catalog generationHi Ajay,
U can use the below code to create a dynamic internal table.
*adding the field names only once for the dynamic table .
MOVE 'PRCTR' TO gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>get_string( ).
INSERT gw_component INTO TABLE gt_components.
MOVE 'RCNTR' TO gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>get_string( ).
INSERT gw_component INTO TABLE gt_components.
MOVE 'RACCT' TO gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>get_string( ).
INSERT gw_component INTO TABLE gt_components.
MOVE 'RYEAR' TO gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>get_string( ).
INSERT gw_component INTO TABLE gt_components.
MOVE 'YTDBAL' TO gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>get_string( ).
INSERT gw_component INTO TABLE gt_components.
MOVE 'OBAL' TO gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>get_string( ).
INSERT gw_component INTO TABLE gt_components.
*get structure descriptor -> GR_STRUCTDESCR
gr_structdescr ?= cl_abap_structdescr=>create( gt_components ).
create work area of structure GR_STRUCTDESCR -> GR_WA
CREATE DATA gr_wa TYPE HANDLE gr_structdescr.
ASSIGN gr_wa->* TO <gw_wa>.
determine key components -> GT_KEYS
MOVE lv_value1 TO gw_key-name.
INSERT gw_key INTO TABLE gt_keys.
create descriptor for internal table -> GR_TABLEDESCR
gr_tabledescr ?= cl_abap_tabledescr=>create( p_line_type = gr_structdescr
p_table_kind = cl_abap_tabledescr=>tablekind_hashed
p_unique = abap_true
p_key = gt_keys
p_key_kind = cl_abap_tabledescr=>keydefkind_user ).
create internal table -> GR_ITAB
CREATE DATA gr_itab TYPE HANDLE gr_tabledescr.
ASSIGN gr_itab->* TO <gt_itab>.
CREATE DATA gr_itab LIKE STANDARD TABLE OF <gw_wa>.
ASSIGN gr_itab->* TO <gt_sttab>.
Now u r internal table named <gt_sttab> has been created with fields like RCNTR, PRCTR,RACCT, RYEAR etc whatever the field u need u can go ahead and create dynamically.
then by using the table <gt_sttab> u can create u r field catalog.
Regards,
Rose. -
Hi ,
I have a requirement in which the selection screen of the report contains a field called period .
Suppose the report is run on say the month of December and the period value they entered in selection screen is 4 .
The ALV should show the values for 4 months prior to december ie Aug,Nov,Sept,Oct,Nov,and Dec.
How to dynamically modify the fieldcatalog in ALV in that case
Thanks in advance
Arshad.AHello Arshad
Assuming that the user cannot go back further than the current year the maximum value for period will be 11 (e.g. current month is December then show range January - December).
Simply prepare your fieldcatalog contain 12 columns (1 for each month). Lets assume the columns are named: MONTH_01, MONTH_02, ..., MONTH_12.
Let's take your example (December + 4 periods).
* Get number for current month
ld_current_month = syst-datum+4(2).
ld_month_from = ld_current_month - p_periods. " (= 12 - 4 = 8 = August)
LOOP at gt_fcat INTO ls_fcat
WHERE ( fieldname CS 'MONTH' ).
If ( ls_fcat-fieldname+6(2) BETWEEN ld_month_from AND ld_current_month ).
* keep
ELSE.
ls_fcat-tech = 'X'. " no output on ALV list
ENDIF.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
ENDLOOP.
The restriction to the current year can be overcome the same way yet the coding will get somewhat more complex.
Regards
Uwe -
Problem in filling field catalog as table is dynamic
Hi All,
I have to populate the data using the below function module and i am passing dynamic internal table <f_list> in place of list.
i have to populate the field catalog fc_hier which is getting field by standard program but i have to add additional fields which are coming from dynamic internal table .
fc_hier-fieldname = l_fld_name.
fc_hier-tabname = <f_list>.
fc_hier-seltext_s = wa_char-name_char.
append fc_hier . >>>> but it is not allowing this fc_hier-tabname = <f_list> statement..*
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_interface_check = g_interface_check "n777869
i_callback_program = alv_repid
i_callback_pf_status_set = 'SET_STATUS'
i_callback_user_command = 'USER_COMMAND'
is_layout = alv_layout
is_print = alv_pri
it_fieldcat = fc_hier[]
i_default = 'X'
i_save = 'A'
is_variant = alv_variant
it_events = gt_events[] "n777869
i_tabname_header = 'HEADER'
i_tabname_item = 'LIST'
is_keyinfo = alv_keyinfo
TABLES
t_outtab_header = header[]
t_outtab_item = <f_list>
t_outtab_item = list[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
How can i assign table name to fc_hier-tabname as it is not taking <f_list> as input.
Thanks in advance......
Ankur>
ankur garg wrote:
> fc_hier-fieldname = l_fld_name.
> fc_hier-tabname = <f_list>.
> fc_hier-seltext_s = wa_char-name_char.
> append fc_hier . >>>> but it is not allowing this fc_hier-tabname = <f_list> statement..*
>
> How can i assign table name to fc_hier-tabname as it is not taking <f_list> as input.
TABNAME is the name of the table & not the body of the table (TYPE slis_tabname CHAR30). You have to pass the name of the table & not the table contents !!
Something like this :
fc_hier-fieldname = l_fld_name.
fc_hier-tabname = '<F_LIST>'.
fc_hier-seltext_s = wa_char-name_char.
append fc_hier.
Anyways personally if i have dynamic tables to be used in ALV i prefer SALV which doesn't need a fieldcat
BR,
Suhas -
Build field catalog for dynamic data objects
Hi
Could you please tell me how to build a field catalog (ooops alv) for an internal table which is a dynamic data object.
TYPES: BEGIN OF t_addsubty,
subty TYPE subty,
pernr TYPE persno,
END OF t_addsubty.
TYPES: ty_addsubty type t_addsubty occurs 1.
i have data object using these
CREATE DATA dref3 TYPE (g_type1).
ASSIGN dref3->* TO <fs_dp>.
where g_type1 refers a data type which i defined in the program. g_type1 = ty_addsubty.
now <fs_dp> refers to an internal table.
now i want to build a field catalog for this internal table.
In my program <fs_dp> structure is not always the same. i.e now it is ty_addsubty but for some other conditions the structure is different.
please help me out.
regards
badriHere some piece of code, which shows how it works:
<SNIP>
type-pools:
abap.
DATA:
lr_tabledescr TYPE REF TO cl_abap_tabledescr,
lr_structdescr TYPE REF TO cl_abap_structdescr.
field-symbols:
<lw_component> type abap_compdescr_tab.
TYPES:
BEGIN OF t_addsubty,
subty TYPE subty,
pernr TYPE persno,
END OF t_addsubty.
TYPES:
ty_addsubty type t_addsubty occurs 1.
CREATE DATA dref3 TYPE (g_type1).
ASSIGN dref3->* TO <fs_dp>.
lr_tabledescr ?= cl_abap_tabledescr=>describe_by_data( <fs_dp> ).
assert condition lr_tabledescr is bound.
lr_structdescr ?= lr_tabledescr->get_table_line_type( ).
loop at lr_structdescr->components assigning <lw_component>.
* do whatever you want with the information about
* the components of the structure
endloop.
</SNIP>
Do not forget to reward points... -
Building Field-Catalog for dynamic internal tables
Hi All,
I created a dynamic internal table(<fs_final>,<fs_final_line>) and populated data into it.Now I want to provide field catalog to these dynamic internal table.
Can anyone suggest me the how to create a field catalog for existing dynamic internal table.Thanks in advance.
Regards,
Chakradhar.
Moderator message - Please use proper subject line in future.
Message was edited by: Suhas SahaUse this code to get all components of internal table.
Then build fieldcatlog.
DATA: tab_return type abap_compdescr_tab,
components like line of tab_return.
perform get_int_table_fields using <fs_it> changing tab_return.
loop at tab_return into components.
wa_fldcat-fieldname = components-name. "Field Name
wa_fldcat-scrtext_m = components-name. "Column Heading
wa_fldcat-inttype = components-type_kind. "Data Type
wa_fldcat-intlen = components-length. "Data Lenght
wa_fldcat-decimals = components-decimals. "Data Decimal Places
append wa_fldcat to it_fldcat.
endloop.
form get_int_table_fields using t_data type any table
changing t_return type abap_compdescr_tab.
data:
oref_table type ref to cl_abap_tabledescr,
oref_struc type ref to cl_abap_structdescr,
oref_error type ref to cx_root,
text type string.
*Get the description of data object type
try.
oref_table ?=
cl_abap_tabledescr=>describe_by_data( t_data ).
catch cx_root into oref_error.
text = oref_error->get_text( ).
write: / text.
exit.
endtry.
*Get the line type
try.
oref_struc ?= oref_table->get_table_line_type( ).
catch cx_root into oref_error.
text = oref_error->get_text( ).
write: / text.
exit.
endtry.
append lines of oref_struc->components to t_return.
endform.
Regards
Sreekanth -
Hi Friends,
Please help me out, I am new to ABAP.
Please anybody explain me the functionality of Field catalogs in ALVs?
How many methods are there to pass data to ALVs, i.e., in how many ways?
Hope u will help me.hi,
this will be very helpful for ALV REPORTING.....
Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain upto 90 columns in the display with the wide array of display options.
The commonly used ALV functions used for this purpose are;
1. REUSE_ALV_VARIANT_DEFAULT_GET
2. REUSE_ALV_VARIANT_F4
3. REUSE_ALV_VARIANT_EXISTENCE
4. REUSE_ALV_EVENTS_GET
5. REUSE_ALV_COMMENTARY_WRITE
6. REUSE_ALV_FIELDCATALOG_MERGE
7. REUSE_ALV_LIST_DISPLAY
8. REUSE_ALV_GRID_DISPLAY
9. REUSE_ALV_POPUP_TO_SELECT
The different steps used for getting the above function modules into use are:
Step 1
DATA DECLARATION
Sap standard type pools: SLIS , KKBLO .
Sap standard tables types taken from the type pools are: SLIS_LAYOUT_ALV ,
SLIS_T_FIELDCAT_ALV,
SLIS_T_LISTHEADER,
SLIS_T_EVENT,
SLIS_SELFIELD.
Internal tables to used in the program declared based on the above table types
DATA: I_LAYOUT TYPE SLIS_LAYOUT_ALV,
I_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
I_HEADING TYPE SLIS_T_LISTHEADER,
I_EVENTS TYPE SLIS_T_EVENT.
TYPES: KKBLO_SELFIELD TYPE SLIS_SELFIELD.
Step 2 (Optional)
SELECTING THE VARIANTS FOR INITIAL LIST DISPLAY (DEFAULT VARIANT)
The variants in the list display can be both user-specific and general. The user can programmatically set the initial (default) variant for list display.
The default variant can be found using the function module 'REUSE_ALV_VARIANT_DEFAULT_GET'.
Sample code:
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = variant save condition ( A=all, U = user-specific )
CHANGING
cs_variant = internal table containing the program name (and the default variant---optional )
EXCEPTIONS
not_found = 2.
The user can also choose from the list of existing variants using the function module REUSE_ALV_VARIANT_F4.
Step 3
DEFININING OUTPUT CHARACTERISTICS: PREPARING DISPLAY FIELDS CATALOG
A field catalog is prepared using the internal table (I_FIELDCAT) of type SLIS_T_FIELDCAT_ALV. Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields).
A field catalog is required for every ALV list output to add desired functionality (i.e. Key, Hotspot, Specific headings, Justify, Col. position etc) to certain fields of the output. If not mentioned specifically, then the defaults are taken. The possible values and defaults are listed below.
The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module.
The minimal field catalog is documented below. This can be done in a routine using a local variable. The user can use the other optional parameters to assign output attributes to different fields in the output, which differ from the default.
A field catalog need not be built-up and passed explicitly only under the following conditions:
1. The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE. In this case the attributes of the different fields is taken directly from the table and the attributes (key fields, length, texts etc) need to state explicitly.
2. all fields in this structure are to be output
3. The structure name is passed to ALV in the parameter I_STRUCTURE_NAME of the function module REUSE_ALV_LIST_DISPLAY.
All the values entered in the catalog is specific to the particular field whose name is entered in the fieldname FIELDNAME of the fieldcat structure. The name of the table is also entered in the corr. Fieldname TABNAME of the structure.
The different possible attributes are:
Row_pos (row position): Only relevant if the list output is to be multi-line (two or three lines) by default. So, this attribute can be used maintain certain level of alignment in the output.
Value set: 0, 1 3
Col_pos (column position): This parameter is relevant when the fields in the output are to be different from the sequence of the fields in the internal table used for display. The parameter specifies the relative column position of the field in the list output. The column order can be changed interactively by the user. If this parameter is initial for all field catalog entries, columns appear in the internal table field sequence.
Value set: 0, 1 60
Fieldname (field name): This is the name of the internal table field for which the parameters are passed in the catalog.
Value set: internal output table field name (required parameter)
Tabname (internal output table): Name of the internal output table that contains the field FIELDCAT-FIELDNAME above.
Value set: SPACE, internal output table name.
Ref_fieldname (reference field name): Name of the Data Dictionary field referred to. This parameter is only used when the internal output table field described by the current field catalog entry has a reference to the Data Dictionary (not a program field), and the field name in the internal output table is different from the name of the field in the Data Dictionary. If the field names are identical, naming the Data Dictionary structure or table in the FIELDCAT-REF_TABNAME parameter is sufficient.
Value set: SPACE, Data Dictionary field name.
Ref_tabname (reference table/structure field name): Structure or table name of the referred Data Dictionary field. This parameter is only used when the internal output table field described by the current field catalog entry has a Data Dictionary reference (not a program field).
Value set: SPACE, name of a Data Dictionary structure or table
Link to currency unit
Cfieldname (currency unit field name): This is used for currency fields that have a reference to any unit field. This is only relevant for amount columns with associated unit. This parameter contains the Name of the internal output table field containing the currency unit associated with the amount field FIELDCAT-FIELDNAME. The field in FIELDCAT-CFIELDNAME must have its own field catalog entry.
Value set: SPACE, output table field name
Ctabname (internal currency unit field output table): Name of the internal output table containing the FIELDCAT-CFIELDNAME field.
Value set: SPACE, output table field name.
Link to measurement unit
Qfieldname (measurement unit field name): Only relevant for quantity columns with unit link. Name of the internal output table field containing the measurement unit associated with the quantity field FIELDCAT-FIELDNAME. The field in FIELDCAT-QFIELDNAME must have its own field catalog entry.
Value set: SPACE, output table field name.
Qtabname (internal measurement unit field output table): Name of the internal output table containing the FIELDCAT-QFIELDNAME field.
Value set: SPACE, output table field name.
Outputlen (column width): This parameter is used if the desired output length for a field is desired to be different from the internal output table field. For fields with a Data Dictionary link this parameter can be left initial. For fields without a Data Dictionary link (program field) the parameter must be given the value of the desired field list output length (column width).
Initial = column width is the output length of the referred Data Dictionary field (domain).
N = column width is n characters.
Value set: 0 (initial), n.
Key (key column): By default, the system makes some fields in the output as key fields, provided the fields are key fields in their referencing table. Using this parameter, fields other than key fields of the referencing table can be made key field. This parameter is most important if the output needs to contain some field which are not scrollable or cannot be hidden.
If the internal output table contains fields that are key fields from different tables, then all those fields in the report output becomes unscrollable and cannot be hidden. So, the fields in the output internal table should not be referenced from tables in which they are key fields. Instead, they should be referenced to the tables in which they are not key fields, incase they are not desired as key field in the output.
'X' = key field (key field output in color) and Key fields can not be interactively hidden. Parameter FIELDCAT-NO_OUT must be left initial.
Value set: SPACE, 'X'.
Key_sel (hideable key column): This parameter is only relevant for the fields which are made key fields using FIELDCAT-KEY = 'X'. Using this parameter the Key field can be hidden interactively.
The key column sequence cannot be changed interactively by the user. The output is controlled by the FIELDCAT-NO_OUT parameter analogously to non-key fields.
Value set: SPACE, 'X'.
No_out (field in field list): This parameter is used to remove certain fields from the output during initial display. The user can however interactively choose the field for output from the field list in the display variant.
'X' = field is not displayed in the current list.
Value set: SPACE, 'X'.
Tech (technical field): This parameter is used to make certain field display only in the field catalog. The fields with this parameter set cannot be output in the list nor can they be displayed interactively from the catalog.
'X' = technical field.
Value set: SPACE, 'X'.
Emphasize (highlight columns in color): As name suggests, this field parameter is used to highlight certain field with chosen colors.
Value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off ,'1'=on).
'X' = column is colored with the default column highlight color.
'Cxyz' = column is colored with a coded color:
- C: Color (coding must begin with C)
- X: color number
- Y: bold
- Z: inverse
Hotspot (column as hotspot): This parameter is used to make certain field appear as hotspot i.e. a hand is displayed if the cursor is positioned on the field value. Single click on such fields cause the PICK OR F2 events to happen.
Value set: SPACE, 'X'.
'X' = column cells are output as hotspots.
Fix_column (fix column): This parameter is used to fix certain columns in the output. All columns to be fixed must have this flag, starting from the left. If a column without this flag is output, only the columns to the left of this column are fixed. The user can change the column fixing interactively.
Value set: SPACE, 'X'.
'X' = column fixed (does not scroll horizontally).
Do_sum (sum over column): the user can also call this function interactively.
Value set: SPACE, 'X'.
'X' = a sum is calculated over this internal output table field.
No_sum (sums forbidden): No sum can be calculated over this field, although the data type of the field would allow summing.
Value set: SPACE, 'X'.
Icon: The parameter displays certain column contents as icons. The internal output table column contents must be valid icon strings.
Value set: SPACE, 'X'.
'X' = column contents to be output as an icon.
Symbol: The internal output table column must be a valid symbol character.
Value set: SPACE, 'X'
'X' = column contents are to be output as a symbol.
Just (justification): This parameter is used for alignment of the contents of the output table. This is only relevant for CHAR or NUMC fields in the output internal table. The justification of the column header always follows the justification of the columns. Independent justification of the column header is not possible.
Value set: SPACE, 'R', 'L', and C.
' ' = Default justification for this data type
'R' = right-justified output
'L' = left-justified output
'C' = centered output.
Lzero (leading zeros): By default ALV outputs NUMC fields right-justified without leading zeros. Using this parameter only the NUMC fields can be displayed with leading zeroes.
Value set: SPACE, 'X'.
'X' = output with leading zeros.
No_sign (no +/- sign): This parameter is used to suppress the signs of the output fields. It is only relevant for the value fields.
Value set: SPACE, 'X'.
'X' = value output without +/ sign.
No_zero (suppress zeros): Only relevant for value fields.
Value set: SPACE, 'X'.
'X' = suppress zeros.
Edit_mask (field formatting): To apply the report output formatting options same as in the WRITE statement in report writing.
Value set: SPACE, template.
The following parameters are used for customizing the texts in the heading of the output of the columns. The texts are taken from the Data Dictionary for fields with a Data Dictionary reference. If this is not desired, the text parameters can also be specified. The Data Dictionary texts are then ignored.
If the user changes the column width interactively, the column header text with the appropriate length is always used.
The interactive function 'Optimize column width' takes account of both the field contents and the column headers: if all field contents are shorter than the shortest column header, the column width depends on the column header.
The 'long field label' is also used in display variant definition,
Sort, etc. Popup.
seltext_l (long field label)
seltext_m (medium field label)
seltext_s (short field label)
reptext_ddic(header) Analogous to the Data element main header
Ddictxt (specify text) : You can specify with values 'L', 'M', and 'S', the keyword that should always be used as column header. If the column width changes, no attempt is made in this case to find an appropriate header for the new output width.
Value set: SPACE, 'L', 'M', and S.
Sample code:
Suppose I_PO_DETAILS is an internal table containing two fields EBELN (PO number) and EBELP (PO item no).
DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV. Local variable to hold the parameters
for a particular field of the field catalog
CLEAR L_FIELDCAT.
L_FIELDCAT-TABNAME = 'I_PO_DETAILS'.
L_FIELDCAT-FIELDNAME = 'EBELN'.
L_FIELDCAT-KEY = 'X'. The PO no is made the key field,
Colored and non scrollable
L_FIELDCAT-HOTSPOT = 'X'. The po no becomes a hotspot
L_FIELDCAT-SELTEXT_S = P.O No.
L_FIELDCAT-SELTEXT_M = 'P order No'.
L_FIELDCAT-SELTEXT_L = 'Purchase order No'.
APPEND L_FIELDCAT TO I_FIELDTAB.
CLEAR L_FIELDCAT
L_FIELDCAT-TABNAME = 'I_PO_DETAILS'.
L_FIELDCAT-FIELDNAME = 'EBELN'.
L_FIELDCAT-KEY = 'X'. The po item no is made the key field,
Colored and non scrollable
L_FIELDCAT-SELTEXT_S = 'Item No'.
L_FIELDCAT-SELTEXT_M = 'Item No`.
L_FIELDCAT-SELTEXT_L = 'PO Item No'.
APPEND L_FIELDCAT TO I_FIELDTAB.
CLEAR L_FIELDCAT
Thus the catalog for the report output is prepared.
Step 4
The next step is to build an event table, which are used for firing both user commands and the system dependent events i.e. top of page, end of page etc.
A list of possible events is populated into an event table (I_EVENTS) when this table is passed to the function module REUSE_ALV_EVENT_NAMES_GET. The return table from this function module contains all the possible events.
The function module contains following import and export parameters.
IMPORTING PARAMETERS: I_LIST_TYPE
This parameter has possible values from 0-4.
The parameter I_LIST_TYPE is of TYPE SLIS_LIST_TYPE and is DEFAULT 0 .
EXPORTING PARAMETERS: I_EVENTS table.
This table is of TYPE SLIS_T_EVENT and returns to the program the name of all the possible events.
The table structure contains the fields:
I_EVENTS-NAME: Name of the Callback event.
I_EVENTS-FORM: Name of the form routine that should be called in the calling program at the event.
Only events with a form routine name are processed.
The I_EVENTS table returns with the following possible constants:
1. Slis_ev_item_data_expand TYPE slis_formname VALUE 'ITEM_DATA_EXPAND'.
Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT. Exit for passing item entries (ITEM table) for a header record that was expanded interactively by the user.
2. Slis_ev_reprep_sel_modify TYPE slis_formname VALUE 'REPREP_SEL_MODIFY'.
RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header that is to be expanded.
RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in the item table.
RS_SELFIELD is initial in this case.
3. Slis_ev_caller_exit_at_start TYPE slis_formname VALUE 'CALLER_EXIT'.
Is called at the beginning of the function module to make special settings. It is not usually used.
4. Slis_ev_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
As this is a frequently-used Callback event, the form routine can also be passed directly in the interface by passing the user command in the IMPORTING parameter I_CALLBACK_USER_COMMAND.
5. Slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
Equivalent to the list processing TOP-OF-PAGE event.
6. Slis_ev_top_of_coverpage TYPE slis_formname VALUE 'TOP_OF_COVERPAGE'.
The selection information and list status are output together (if they exist) on a separate page by default
7. Slis_ev_end_of_coverpage TYPE slis_formname VALUE 'END_OF_COVERPAGE'.
Analogously to TOP_OF_COVERPAGE the user can add other information
to the information output by ALV (selection information, list status) at this event.
8. Slis_ev_foreign_top_of_page TYPE slis_formname VALUE FOREIGN_TOP_OF_PAGE'.
The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).
In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.
9. Slis_ev_foreign_end_of_page TYPE slis_formname VALUE 'FOREIGN_END_OF_PAGE'.
The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).
In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.
10. Slis_ev_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET'.
If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).
The STANDARD status of the function group SALV should be used as a template for a user-specific status. As this is a frequently used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.
11. Slis_ev_list_modify TYPE slis_formname VALUE 'LIST_MODIFY'.
LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME
R_INDEX LIKE SY-TABIX
R_INDEX_ITEM LIKE SY-TABIX
R_INDEX_SUM LIKE SY-TABIX.
12. Slis_ev_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST'.
Information output at the start of the list
13. Slis_ev_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.
Information output at the end of a page. This is only called for printing.
14. Slis_ev_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'.
Information output at the end of the list
15. Slis_ev_after_line_output TYPE slis_formname VALUE 'AFTER_LINE_OUTPUT'.
Output information after each output line. Should only be used in justified cases because it costs a lot of performance.
16. Slis_ev_before_line_output TYPE slis_formname VALUE 'BEFORE_LINE_OUTPUT'.
Output information before each output line. Should only be used in justified cases because it costs a lot of performance.
17. Slis_ev_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.
This event table (I_EVENTS) is now checked with the desired constants. If the desired constant is found, then the corresponding field for the FORM NAME is populated with the name of the routine containing the corresponding event.
Sample code :
FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE', FORMNAME_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
DATA: L_I_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = I_EVENTS.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_TOP_OF_PAGE TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_END_OF_PAGE TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
CLEAR L_I_EVENT.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_USER_COMMAND TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
This will prepare the events table for the report.
The report will contain three forms for the above events:
1. FORM TOP_OF_PAGE : This form will contain the top of page event for the report i.e header etc
Using the function module REUSE_ALV_COMMENTARY_WRITE, the internal table containing the headings for top of page event can be passed to the list output. Also, any logo specific to the report can be passed to the function module.
2. FORM END_OF_PAGE : This form will contain the end of page event for the report i.e footer etc
3. FORM USER_COMMAND : This form will contain the desired user command i.e pick/line selection
Step 5
A layout is build for the report output list description USING the internal table declared above (I_LAYOUT).
Output list description structure.
The parameters are described under the following heads:
Display options
Exceptions
Totals
Interaction
Detail screen
Display variants (only for hierarchical-sequential lists)
Color
Other
The layout table is of type slis_layout_alv_spec and has the following fields:
Display options
1. Colwidth_optimize (1) TYPE c: This parameter optimizes the length of the different columns in the output. The width of the different col. now depends on the max. Length of the data in the column.
Value set: SPACE, 'X'
'X' = optimizes the column width so that all contents are displayed completely.
2. No_colhead(1) TYPE c : This parameter suppresses the column headings
Value set: SPACE, 'X'.
'X' = column headers are not output
3. No_hotspot(1) TYPE c : The heading of the report output are not output as hotspot.
Value set: SPACE, 'X'.
'X' = column headers are not output as hotspot
4. Zebra(1) TYPE c : The report is output in the striped pattern.
Value set: SPACE, 'X'.
'X' = striped pattern (e.g. for wide lists)
5. No_vline(1) TYPE c : The report output contains columns only separated by space and no lines. It is not relevant for: hierarchical-sequential lists and multiple-line lists.
Value set: SPACE, 'X'.
'X' = columns separated by SPACE
6. No_min_linesize(1) TYPE c : The report line size is equal to the width of the list. It is not relevant for block lists.
Value set: SPACE, 'X.
'X' = line size depends on list width
' ' = Line size is set to 80 or MIN_LINESIZE (if > 0) .
7. Min_linesize LIKE sy-linsz: The report output contains a minimum possible length of line. If initial min_linesize is set to 80 by default, then this parameter is used to customize it. The prerequisite for this is that the parameter no_min_linesize should be ' '.
Value set: 0, 10 - 250
If the list is wider, the format uses the list width (maximum 250 or MAX_LINESIZE (if > 0)).
8. Max_linesize LIKE sy-linsz: The default max. Linesize is 250. To change this default value, this parameter can interactively-define the maximum list width setting.
Value set: 0, 80 - 1020
9. Window_titlebar LIKE rsmpe-tittext: To set the titlebar on the report output.
10. No_uline_hs(1) TYPE c.
Exceptions
11. Lights_fieldname TYPE slis_fieldname: Internal output table field containing the codes of exceptions to be output.
Output table field code: '1' = red traffic light
'2' = yellow traffic light
'3' = green traffic light Fieldname for exception
Value set: SPACE, internal output table field name.
12. Lights_tabname TYPE slis_tabname: Name of the internal output table that contains the field in the parameter LIGHTS_FIELDNAME. If LIGHTS_FIELDNAME is not empty, this field must also be filled for hierarchical-sequential lists. Only relevant for hierarchical-sequential lists.
. Value set: SPACE, internal output table name.
13. Lights_rollname LIKE dfies-rollname: The documentation of this data element is displayed when you call F1 help for an exception column.
Value set: SPACE, data element name.
14. Lights_condense(1) TYPE c : If a list record is output with 'red traffic light', each
Subtotal that includes this record is also output with 'red traffic light'.
Value set: SPACE, 'X'
'X' = the 'maximum' exception of the items in the subtotal is output at subtotal level.
Sums
15. No_sumchoice(1) TYPE c : This parameter allows the choice for summing up
Only by fieldcatalog.
Value set: SPACE, 'X'
'X' = fields which are to be summed, passed by the calling program (FIELDCAT-DO_SUM = 'X'). The user should not be able to change this value interactively.
16. No_totalline(1) TYPE c : Removes the option of having totals after sub-totals.
Value set: SPACE, 'X'
'X' = no total record is to be output. Subtotals can still be calculated and output. The fields in the subtotals are flagged DO_SUM = 'X' in the field list.
17. No_subchoice(1) TYPE c : Does not allow the user to interactively change the field chosen for subtotals.
Value set: SPACE, 'X'
'X' = value whose change triggers subtotals, provided by the calling program. The user should not be able to change this value interactively.
18. No_subtotals(1) TYPE c : No subtotals possible
Value set: SPACE, 'X'
'X' = no subtotals.
19. Numc_sum(1) TYPE c : Totals only possible for NUMC-Fields.
20. No_unit_splitting TYPE c: No separate total lines by inh.units
21.totals_before_items TYPE c: Display totals before the items
22. Totals_only(1) TYPE c : Show only totals
Value set: SPACE, 'X'
'X' = only total records are output.
23. Totals_text(60) TYPE c : Text for 1st col. in totals
Value set: SPACE, string (max.60)
' ' = The first column in the total record contains an appropriate number of '*'s to indicate the total by default. If the first column is wide enough, the string 'Total' is output after the asterisks.
'String = The string passed is output after the total indicated by '*', if the column is wide enough.
24. Subtotals_text(60) TYPE c : Texts for subtotals
Value set: SPACE, string (max.60)
' ' = In the first column of subtotal records, the subtotal is indicated by an appropriate number of '*' by default. If the first column is not a subtotal criterion, the string 'Total' is output after the asterisks, if the column is wide enough.
'String = the string passed is output after the subtotal indicated by '*', if the column is wide enough and the first column is not a subtotal criterion. If it is a subtotal criterion, its value is repeated after the total, if the column is wide enough.
Interaction
25. Box_fieldname TYPE slis_fieldname: Fieldname for checkbox in the report output. If the list has checkboxes at the start of records (for selecting several records), this parameter contains the internal output table field name indicated by the checkbox selection column. The field is a checkbox at the start of list records without a list header.
Value set: SPACE, internal output table field name
26. Box_tabname TYPE slis_tabname: Name of the internal output table that contains the field in the parameter BOX_FIELDNAME. If BOX_FIELDNAME is not empty, this field must also be filled for hierarchical-sequential lists.
Value set: SPACE, internal output table name.
27. Box_rollname LIKE dd03p-rollname: rollname for checkbox
28. Expand_fieldname TYPE slis_fieldname: fieldname flag expand. The user can show or hide the items by clicking on the folder symbol (hotspot). If the items for a header entry are only to be read by the calling program and passed to ALV when a header has been expanded interactively, this can be controlled via the CALLBACK event 'ITEM_DATA_EXPAND'.
29. Hotspot_fieldname TYPE slis_fieldname: Used to make the fieldname flag hotspot.
30. No_input(1) TYPE c : The fields are only display fields.
Value set: SPACE, 'X'
'X' = all ready-for-input fields in a list are displayed as not ready-for-input. (Record selection checkboxes and fields which can be made ready-for-input via the field list parameter FIELDCAT-INPUT = 'X')
31. F2code LIKE sy-ucomm: To assign an ALV standard function code to double-click (F2), assign the function code to this parameter. Ex.: to assign the ALV standard function 'Detail' ('&ETA') to F2.
=> LAYOUT-F2CODE = '&ETA'.
Value set: SPACE, function code
32. Confirmation_prompt: confirm. Prompt when leaving
Value set: SPACE, 'X'
'X' = if one of the functions Back (F03)', Exit (F15)' or Cancel (F12)' occurs, a confirmation prompt appears.
33. Key_hotspot(1) TYPE c : The key fields are displayed as hotspot. The columns defined in the field catalog as key fields (FIELDCAT-KEY = 'X') are output as hotspots, i.e. clicking on a key column (highlighted in color in the list) calls the function under F2.
Value set: SPACE, 'X'.
34. Reprep(1) TYPE c : report report interface active.
35. Group_buttons(1) TYPE c : group-buttons for COL1 - COL5 . Group output fields via FIELDCAT-SP_GROUP in the field list, and pass the group name to the list module in the interface parameter IT_SPECIAL_GROUPS.
Value set: SPACE, 'X'.
36. No_keyfix(1) TYPE c : Used to make the key fields scrollable.
Value set: SPACE, 'X'.
' ' = The key columns defined in the field catalog by FIELDCAT-KEY = 'X' are fixed in the list output. These columns do not scroll horizontally. The item table key columns are fixed in hierarchical-sequential lists. The header table key fields are not considered here.
'X' = key columns not fixed
37. Get_selinfos(1) TYPE c : To read selection screen.
Value set: SPACE, 'X'.
If the calling program is a report with an ABAP/4 selection screen, setting this parameter makes ALV read the selection screen again. If the selections are read successfully, a pushbutton, via which the user can call a popup which lists the report selections in a simple form, becomes active on the results list output by ALV.
38. group_change_edit(1) TYPE c : Settings by user for new group
Value set: SPACE, 'X'
'X' = the user can enter a format option for each sort criterion in the sort/subtotal popup, for the list format when this value changes (e.g. new page or underline).
39. No_scrolling(1) TYPE c : Does not allow scrolling of the list to the right.
Value set: SPACE, 'X'.
40. Expand_all(1) TYPE c : Expand all positions
Detailed screen
40. Detail_popup(1) TYPE c : show detail in popup.
Value set: SPACE, 'X'
' ' = List record detail display in full-screen mode, with top-of-page.
'X' = list record detail display in popup (without top-of-page).
41. Detail_initial_lines(1) TYPE c : show also initial lines
Value set: SPACE, 'X'
' ' = Only fields whose contents are not initial are output in the detail view.
'X' = initial field contents are also output in detail.
41. detail_titlebar(30) type c : Titlebar for detail screen
Value set: SPACE, string (max.30)
` ' = ' Detail: Display' is output as the title of the detail window.
'String = the string passed is output as the title of the detail window.
Display variants
42. Header_text (20) TYPE c: Text for header button. Only relevant for hierarchical-sequential lists. You can toggle between display field and field list views via pushbuttons in the display variant definition popup for hierarchical-sequential lists. The views refer to the hierarchy level of the fields. This is technically a toggle between the header table and item table fields.
Value set: SPACE, CHAR (20)
' ' = The header table field pushbutton text is 'Header' by default.
CHAR (20) = header table field pushbutton text.
43.item_text(20) TYPE c : Text for item button. Only relevant for hierarchical-sequential lists. You can toggle the view between the display fields and the field list via pushbuttons in the display variant definition popup for hierarchical-sequential lists. The views refer to the hierarchy level of the fields. This is technically a toggle between the header table and item table fields.
Value set: SPACE, CHAR (20)
' ' = The pushbutton text for the item table fields is 'Item' by default.
CHAR (20) = item table field pushbutton text.
44.default_ item(1) TYPE c : Items as default. Only relevant for hierarchical-sequential lists.
Value set: SPACE, 'X'
' ' = The header table fields are displayed by default in the display variant definition popup. The user can switch to the item table fields interactively.
'X' = the item table fields are displayed by default in the display variant Definition Popup. The user can switch to the header table fields interactively.
Colour
45. Info_fieldname TYPE slis_fieldname: infofield for listoutput. A whole list record can be colored individually using a color code in a column of the internal output table for the record. Assign the name of the field containing the color code to this parameter.
Value set: SPACE, internal output table field name
The internal output table field must be of type CHAR(3).
The code must have the following syntax: 'Cxy':
C = color (all codes must start with 'C')
X = color number ('1'-'9')
Y = bold ('0' = off, '1' = on)
46. Coltab_fieldname TYPE slis_fieldname: Cells can be colored individually using a color code which is contained in a column of the internal output table for the record containing the cell. Assign the name of the field to this parameter.
Others
47. List_append(1) TYPE c : no call screen. It is only useful to output block-lists without specifying the above modules if the number of list blocks exceeds, or may exceed, the maximum number specified in the block module documentation. These operations are not possible for user-defined block lists.
Example code :
I_LAYOUT-f2code = ws_fcode.
I_LAYOUT-zebra = 'X'.
I_LAYOUT-colwidth_optimize = 'X'.
I_LAYOUT-no_keyfix = 'X'.
I_LAYOUT-get_selinfos = 'X'.
I_LAYOUT-no_hotspot = 'X'.
I_LAYOUT-no_input = 'X'.
I_LAYOUT-hotspot_fieldname = FIELDNAME.
I_LAYOUT-no_input = X.
I_LAYOUT-no_vline = `X.
I_LAYOUT-no_colhead = .
I_LAYOUT-lights_condense = ` `.
I_LAYOUT-totals_text = ` `.
I_LAYOUT-subtotals_text = ` `.
I_LAYOUT-totals_only = ` `.
I_LAYOUT-key_hotspot = X.
I_LAYOUT-detail_popup = X.
I_LAYOUT-group_change_edit = X.
I_LAYOUT-GROUP_BUTTONS = X.
Step 6
This step is required to get the selection screen information in the report output.
The prerequisite for this is to set the parameter LAYOUT-GET_SELINFOS of the IMPORTING structure.
The parameters to be passed in the IS_SEL_HIDE table are:
o mode: 'R' = only the entries passed in the internal table IS_SEL_HIDE-T_ENTRIES
Are output in the pop up. Selection info, which the list tool read in the selection screen (when called by a report with a selection screen), is replaced by the values passed.
'S' = the selection info which the list tool read in the selection screen of the calling report are modified by the entries in the table IS_SEL_HIDE-T_ENTRIES.
o t_entries: Selection info table
o t_entries-mode: 'A' = output the selection info for the current table record in the info popup.
'D' = do not output select option or SELNAME parameter selection info in the popup.
o t_entries-selname: (only used in t_entries-mode = 'D') : Name of the select option or parameter.
The following table fields are only used in t_entries-mode = 'A'. They contain the selection information to be added.
t_entries-field: DDIC field name of the field for which selection information is to be output.
t_entries-table: DDIC table names of t_entries-field.
t_entries-stext: Field name in info popup.
If t_entries-field and t_entries-table have been entered, this text is taken from DDIC.
t_entries-valuf: Selection condition 'from' value (external format)
t_entries-valut: Selection condition 'to' value (external format)
t_entries-sign0: (I)nclusive (E)xclusive
t_entries-option: All values of the select options Option field allowed.
Step 6
The Table IT_SORT is populated with the sort criteria for the different fields.
The caller specifies the sorting and/or subtotaling of the basic list in the internal table IT_SORT.
This internal table has the following fields:
o spos : Sort sequence
o fieldname : Internal output table field name
o tabname : Only relevant for hierarchical-sequential lists. Name of the internal output table.
o up : 'X' = sort in ascending order
o down : 'X' = sort in descending order
o subtot : 'X' = subtotal at group value change
o group : '* ' = new page at group value change ,'UL' = underline at group value change
Step 7
The final step in the output of the report is the use of two ALV functions modules.
1. REUSE_ALV_FIELDCATALOG_MERGE
2. REUSE_ALV_LIST_DISPLAY
The first function module is used to pass the field catalog to the report output and merge it with the internal output table.
FUNCTION reuse_alv_fieldcatalog_merge.
""Lokale Schnittstelle:
* IMPORTING
*" VALUE(I_PROGRAM_NAME) LIKE SY-REPID OPTIONAL
*" VALUE(I_INTERNAL_TABNAME) TYPE SLIS_TABNAME OPTIONAL
*" VALUE(I_STRUCTURE_NAME) LIKE DD02L-TABNAME OPTIONAL
*" VALUE(I_CLIENT_NEVER_DISPLAY) TYPE SLIS_CHAR_1
*" DEFAULT 'X'
*" VALUE(I_INCLNAME) LIKE TRDIR-NAME OPTIONAL
*" CHANGING
*" VALUE(CT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV
*" EXCEPTIONS
*" INCONSISTENT_INTERFACE
*" PROGRAM_ERROR
Import parameters
I_PROGRAM_NAME: Program in which the internal output table is declared and populated
I_INTERNAL_TABNAME: Internal output table name
I_STRUCTURE_NAME: Structure name (structure, table, and view)
I_CLIENT_NEVER_DISPL: Hide client fields default X
I_INCLNAME: Data declarations include name
CHANGING parameter
CT_FIELDCAT: Field catalog with field descriptions
The variant based on a program-internal table should only be used for rapid prototyping since the following restrictions apply:
1. Performance is affected since the code of the table definition must always be read and interpreted at runtime.
2. Dictionary reference are only considered if the keywords LIKE or INCLUDE STRUCTURE (not TYPE) are used.
Step 8
The other function module is used to display the internal output table with the contents
FUNCTION reuse_alv_list_display.
""Lokale Schnittstelle:
* IMPORTING
*" VALUE(I_INTERFACE_CHECK) DEFAULT SPACE
*" VALUE(I_CALLBACK_PROGRAM) LIKE SY-REPID DEFAULT SPACE
*" VALUE(I_CALLBACK_PF_STATUS_SET) TYPE SLIS_FORMNAME
*" DEFAULT SPACE
*" VALUE(I_CALLBACK_USER_COMMAND) TYPE SLIS_FORMNAME
*" DEFAULT SPACE
*" VALUE(I_STRUCTURE_NAME) LIKE DD02L-TABNAME OPTIONAL
*" VALUE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV OPTIONAL
*" VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV OPTIONAL
*" VALUE(IT_EXCLUDING) TYPE SLIS_T_EXTAB OPTIONAL
*" VALUE(IT_SPECIAL_GROUPS) TYPE SLIS_T_SP_GROUP_ALV
*" OPTIONAL
*" VALUE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL
*" VALUE(IT_FILTER) TYPE SLIS_T_FILTER_ALV OPTIONAL
*" VALUE(IS_SEL_HIDE) TYPE SLIS_SEL_HIDE_ALV OPTIONAL
*" VALUE(I_DEFAULT) DEFAULT 'X'
" VALUE(I_SAVE) DEFAULT SPACE
" VALUE(IS_VARIANT) LIKE DISVARIANT
" STRUCTURE DISVARIANT DEFAULT SPACE
" VALUE(IT_EVENTS) TYPE SLIS_T_EVENT OPTIONAL
" VALUE(IT_EVENT_EXIT) TYPE SLIS_T_EVENT_EXIT OPTIONAL
" VALUE(IS_PRINT) TYPE SLIS_PRINT_ALV OPTIONAL
" VALUE(IS_REPREP_ID) TYPE SLIS_REPREP_ID OPTIONAL
" VALUE(I_SCREEN_START_COLUMN) DEFAULT 0
" VALUE(I_SCREEN_START_LINE) DEFAULT 0
" VALUE(I_SCREEN_END_COLUMN) DEFAULT 0
" VALUE(I_SCREEN_END_LINE) DEFAULT 0
" EXPORTING
" VALUE(E_EXIT_CAUSED_BY_CALLER)
" VALUE(ES_EXIT_CAUSED_BY_USER) TYPE SLIS_EXIT_BY_USER
" TABLES
" T_OUTTAB
" EXCEPTIONS
" PROGRAM_ERROR
Import parameters
I_INTERFACE_CHECK: Interface consistency check log output.
I_CALLBACK_PROGRAM: Name of the calling program
I_CALLBACK_PF_STATUS_SET: Set EXIT routine to status.
I_CALLBACK_USER_COMMAND: EXIT routine for command handling
I_STRUCTURE_NAME: Internal output table structure name
IS_LAYOUT: List layout specifications
IT_FIELDCAT: Field catalog with field descriptions
IT_EXCLUDING: Table of inactive function codes
IT_SPECIAL_GROUPS: Grouping fields for column selection
IT_SORT: Sort criteria for first list display
IT_FILTER: Filter criteria for first list output
IS_SEL_HIDE : Selection information modification
I_DEFAULT: Initial variant active/inactive logic
I_SAVE: Variants can be saved
IS_VARIANT : Variant information
IT_EVENTS: Table of events to perform IT_EVENT_EXIT : Standard fcode exit requests table
IS_PRINT: Print information
IS_REPREP_ID: Initialization keys for Re/Re interface
I_SCREEN_START_COLUMN: Coordinates for list in dialog box
I_SCREEN_START_LINE: Coordinates for list in dialog box
I_SCREEN_END_COLUMN: Coordinates for list in dialog box
I_SCREEN_END_LINE: Coordinates f -
Help me on field catalog in alv step by step,
Error while running alv field catalouge not found.
points will be awardedHi
Don't declare the internal table with Types which is used in the field catalog..
straight away declare with Occurs o with header line.
See this doc
ABAP List Viewer
The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
This helps us to implement all the features mentioned very effectively.
Using ALV, We can have three types of reports:
1. Simple Report
2. Block Report
3. Hierarchical Sequential Report
There are some function modules which will enable to produce the above reports without much effort.
All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
1. SIMPLE REPORT.
The important function modules are
a. Reuse_alv_list_display
b. Reuse_alv_fieldcatalog_merge
c. Reuse_alv_events_get
d. Reuse_alv_commentary_write
e. Reuse_alv_grid_display
A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
The important parameters are :
I. Export :
i. I_callback_program : report id
ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
iii. I_callback_user_command : routine where the function codes are handled
iv. I_structure name : name of the dictionary table
v. Is_layout : structure to set the layout of the report
vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
II. Tables :
i. t_outtab : internal table with the data to be output
B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
The Important Parameters are :
I. Export :
i. I_program_name : report id
ii. I_internal_tabname : the internal output table
iii. I_inclname : include or the report name where all the dynamic forms are handled.
II Changing
ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
declared in the type pool SLIS.
C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
Parameters :
I. Import :
Et_Events : The event table is returned with all possible CALLBACK events
for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
II. Export :
I_List_type :
0 = simple list REUSE_ALV_LIST_DISPLAY
1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
3 = hierarchical-sequential block list
REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
Parameters :
I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
This internal table has three fields :
Typ : H header, S selection , A - action
Key : only when typ is S.
Info : the text to be printed
E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
Parameters : same as reuse_alv_list_display
This is an example for simple list.
2. BLOCK REPORT
This is used to have multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_BLOCK_LIST_DISPLAY
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
I. I_CALLBACK_PROGRAM
II. I_CALLBACK_PF_STATUS_SET
III. I_CALLBACK_USER_COMMAND
This function module is used to set the default gui status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Parameters :
Export :
I. is_layout : layout settings for block
II. it_fieldcat : field catalog
III. i_tabname : internal table name with output data
IV. it_events : internal table with all possible events
Tables :
i. t_outtab : internal table with output data.
This function module adds the data to the block.
Repeat this function for all the different blocks to be displayed one after the other.
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
This function module is used for hierarchical sequential blocks.
D. REUSE_ALV_BLOCK_LIST_DISPLAY
Parameters : All the parameters are optional.
This function module display the list with data appended by the above function.
Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
3. Hierarchical reports :
Hierarchical sequential list output.
The function module is
A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
Parameters:
I. Export:
i. I_CALLBACK_PROGRAM
ii. I_CALLBACK_PF_STATUS_SET
iii. I_CALLBACK_USER_COMMAND
iv. IS_LAYOUT
v. IT_FIELDCAT
vi. IT_EVENTS
vii. i_tabname_header : Name of the internal table in the program containing the
output data of the highest hierarchy level.
viii. i_tabname_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
ix. is_keyinfo : This structure contains the header and item table field
names which link the two tables (shared key).
II. Tables
i. t_outtab_header : Header table with data to be output
ii. t_outtab_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using REUSE_ALV_FIELDCATALOG_MERGE.
Important Attributes :
A. col_pos : position of the column
B. fieldname : internal fieldname
C. tabname : internal table name
D. ref_fieldname : fieldname (dictionary)
E. ref_tabname : table (dictionary)
F. key(1) : column with key-color
G. icon(1) : icon
H. symbol(1) : symbol
I. checkbox(1) : checkbox
J. just(1) : (R)ight (L)eft (C)ent.
K. do_sum(1) : sum up
L. no_out(1) : (O)blig.(X)no out
M. outputlen : output length
N. seltext_l : long key word
O. seltext_m : middle key word
P. seltext_s : short key word
Q. reptext_ddic : heading (ddic)
R. ddictxt(1) : (S)hort (M)iddle (L)ong
S. datatype : datatype
T. hotspot(1) : hotspot
Reward points if useful
Regards
Anji -
Hallo colleagues,
I have to create a dynamic structure and show it within an ALV.
Therefore I have created my stuctrure like this:
MOVE 'COMP1' TO gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>get_string( ).
INSERT gw_component INTO TABLE gt_components.
MOVE 'COMP2' TO gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>get_i( ).
INSERT gw_component INTO TABLE gt_components.
get structure descriptor -> GR_STRUCTDESCR
gr_structdescr ?= cl_abap_structdescr=>create( gt_components ).
create work area of structure GR_STRUCTDESCR -> GR_WA
CREATE DATA gr_wa TYPE HANDLE gr_structdescr.
ASSIGN gr_wa->* TO <gw_wa>.
So now I have my dynamic structure, but how i can create a field catalog, which fit into the function module 'REUSE_ALV_FIELDCATALOG_MERGE' and 'REUSE_ALV_LIST_DISPLAY'?
Any help?
Thanks in advance
IrianHi,
REPORT zmtable LINE-SIZE 255
LINE-COUNT 65.
Program written by Vijay Chaitanya Raju
Maintain Table dynamicly (Table name is entered on Selection Screen)
Very powerfull program. Please maintain authorisation access and
restrict maintenance to Z-tables
Version 6.20 and up
(can be used in 4.6C with some modifications to block try - endtry
and classes)
Enhanced functionality with dynamic selection screen
TABLES: sscrfields. "Fields on selection screens
TYPE-POOLS rsds.
DATA ds_clauses TYPE rsds_where.
DATA: BEGIN OF ifield OCCURS 0,
fieldname LIKE dd03l-fieldname,
position LIKE dd03l-position,
keyflag LIKE dd03l-keyflag,
datatype LIKE dd03l-datatype.
DATA: END OF ifield.
DATA: sl_step LIKE sy-tabix,
ss_step LIKE sy-subrc,
ss_act(1) TYPE c,
sl_lines LIKE sy-tfill,
sl_status LIKE sy-subrc,
sl_subrc LIKE sy-subrc,
sl_update(1) TYPE c,
sl_mandt(1) TYPE c,
len(6) TYPE n,
f_value(255) TYPE c,
sl_datum LIKE sy-datum,
sl_uzeit LIKE sy-uzeit,
price1(15) TYPE c,
price2(15) TYPE c,
mess(60) TYPE c,
d_stat LIKE sy-subrc,
m_stat LIKE sy-subrc,
slchar(6) TYPE c.
DATA: ref_ptr TYPE REF TO cx_root. "Root class more common
DATA: text TYPE string.
DATA: sl_index LIKE sy-tabix.
DATA: zauth LIKE dd02l-tabname.
DATA: num TYPE i,
max_len TYPE i,
check_len TYPE i,
sl_sel(1) TYPE c.
TYPE-POOLS: icon.
SELECTION-SCREEN.
SELECTION-SCREEN BEGIN OF LINE.
text-012 - 'Table Name'
SELECTION-SCREEN COMMENT 1(25) text-012.
PARAMETERS: tabname LIKE dd02l-tabname DEFAULT 'ZSCARE'.
text-003 - 'Selection'
SELECTION-SCREEN PUSHBUTTON 75(9) text-003 USER-COMMAND sta1.
SELECTION-SCREEN END OF LINE.
numrows(text) - 'Max Number of ROWS'
PARAMETERS: numrows LIKE sy-subrc DEFAULT '100'.
At Selection-Screen *
AT SELECTION-SCREEN.
CASE sscrfields-ucomm.
WHEN 'STA1'.
CLEAR sl_sel.
CALL FUNCTION 'ZSTAN_SELECTIONS'
EXPORTING
tabname = tabname
IMPORTING
ds_clauses = ds_clauses
EXCEPTIONS
table_not_valid = 1
other_error = 2
OTHERS = 3.
IF sy-subrc = 0.
sl_sel = 'X'.
ENDIF.
ENDCASE.
*At Selection-Screen Output *
AT SELECTION-SCREEN OUTPUT.
SELECT SINGLE tabname
INTO tabname
FROM dd02l
WHERE tabname = tabname
AND as4local = 'A'
AND ( tabclass = 'TRANSP' OR tabclass = 'POOL'
OR tabclass = 'CLUSTER' ).
IF sy-subrc <> 0.
MESSAGE 'Table is not valid' TYPE 'S'.
RETURN.
ENDIF.
START-OF-SELECTION.
START-OF-SELECTION.
DEFINE: acheck.
zauth = 'ZTABAUTH'.
select single statu
into sl_update
from (zauth)
where tabname = tabname
and bname = sy-uname.
if sy-subrc <> 0.
message 'You are not authorized to view this table' type 'S'.
return.
endif.
END-OF-DEFINITION.
SELECT SINGLE tabname
INTO tabname
FROM dd02l
WHERE tabname = tabname
AND as4local = 'A'
AND ( tabclass = 'TRANSP' OR tabclass = 'POOL'
OR tabclass = 'CLUSTER' ).
IF sy-subrc <> 0.
MESSAGE 'Table is not valid' TYPE 'S'.
RETURN.
ENDIF.
DATA: ptr_itab TYPE REF TO data.
FIELD-SYMBOLS: <fs_itab> TYPE STANDARD TABLE. "ANY TABLE.
CREATE DATA ptr_itab TYPE STANDARD TABLE OF (tabname).
ASSIGN ptr_itab->* TO <fs_itab>.
For DELETION
DATA: ptr_itd TYPE REF TO data.
FIELD-SYMBOLS: <fs_itd> TYPE STANDARD TABLE.
CREATE DATA ptr_itd TYPE STANDARD TABLE OF (tabname).
ASSIGN ptr_itd->* TO <fs_itd>.
For MODIFICATION
DATA: ptr_itm TYPE REF TO data.
FIELD-SYMBOLS: <fs_itm> TYPE STANDARD TABLE.
CREATE DATA ptr_itm TYPE STANDARD TABLE OF (tabname).
ASSIGN ptr_itm->* TO <fs_itm>.
DATA: ptr_wtab TYPE REF TO data.
FIELD-SYMBOLS: <fs_wtab> TYPE ANY.
CREATE DATA ptr_wtab TYPE (tabname).
ASSIGN ptr_wtab->* TO <fs_wtab>.
DATA: itabname(15) TYPE c.
itabname = '<fs_wtab>'.
Standard list status with 'SAVE' button
SET PF-STATUS 'STLI'.
CLEAR sl_update.
Maintain authorisation access in table ZTABAUTH
Key fields: tabname - Table name
bname = sy-uname - User name
statu = 'X' - maintain
' ' - view
Check authorisation access
acheck.
SELECT fieldname position keyflag datatype
INTO TABLE ifield
FROM dd03l
WHERE tabname = tabname
AND fieldname NOT LIKE '.INCLU%'
ORDER BY position.
FIELD-SYMBOLS: <f1> TYPE ANY.
DATA: tab_field(60) TYPE c,
sline LIKE sy-lisel.
DATA: field_attr LIKE dfies.
DATA: BEGIN OF tfield_attr OCCURS 0.
INCLUDE STRUCTURE field_attr.
DATA: END OF tfield_attr.
LOOP AT ifield.
CALL FUNCTION 'G_FIELD_READ'
EXPORTING
table = tabname
fieldname = ifield-fieldname
text_flag = 'X'
IMPORTING
field_attr = field_attr.
tfield_attr = field_attr.
APPEND tfield_attr.
ENDLOOP.
IF sl_sel = 'X'.
SELECT *
FROM (tabname)
INTO TABLE <fs_itab> UP TO numrows ROWS
WHERE (ds_clauses-where_tab).
ELSE.
SELECT *
FROM (tabname)
INTO TABLE <fs_itab> UP TO numrows ROWS.
ENDIF.
DESCRIBE TABLE <fs_itab> LINES sl_lines.
Show two extra lines to allow addition up to 2 new lines
IF sl_update = 'X'.
DO 2 TIMES.
APPEND INITIAL LINE TO <fs_itab>.
ENDDO.
ENDIF.
DATA: info(22) VALUE 'D - Delete, M - Modify'.
WRITE: / icon_information AS ICON QUICKINFO info.
WRITE ' '.
CLEAR check_len.
LOOP AT tfield_attr.
IF tfield_attr-datatype = 'CLNT'.
CONTINUE.
ENDIF.
len = tfield_attr-outputlen.
IF tfield_attr-keyflag = 'X'.
check_len = check_len + len + 1.
ENDIF.
IF tfield_attr-scrtext_m IS NOT INITIAL.
WRITE: AT (len) tfield_attr-scrtext_m COLOR 1.
ELSE.
WRITE: AT (len) tfield_attr-fieldtext COLOR 1.
ENDIF.
ENDLOOP.
CLEAR ss_step.
CLEAR ss_act.
LOOP AT <fs_itab> INTO <fs_wtab>.
IF sy-tabix LE sl_lines.
ss_step = 1.
ELSE.
CLEAR ss_step.
ENDIF.
In field SS_STEP put D - to delete record
M - to modify/add new record
IF sl_update = 'X'.
WRITE:/ icon_change AS ICON.
IF ss_step = 1.
WRITE: ss_act INPUT ON.
ELSE.
ss_act = 'M'.
WRITE: ss_act.
CLEAR ss_act.
ENDIF.
ELSE.
WRITE:/ icon_display AS ICON.
WRITE: ss_act COLOR 2.
ENDIF.
LOOP AT ifield.
Maintain client dependant tables in the same client
IF ifield-datatype = 'CLNT'.
sl_mandt = 'X'.
CONTINUE.
ENDIF.
CONCATENATE itabname '-' ifield-fieldname INTO tab_field.
ASSIGN (tab_field) TO <f1>.
IF sl_update = 'X'.
IF ifield-keyflag = 'X' AND ss_step IS NOT INITIAL.
WRITE: <f1> COLOR 4.
ELSE.
WRITE: <f1> INPUT ON.
ENDIF.
ELSE.
IF ifield-keyflag = 'X' AND ss_step IS NOT INITIAL.
WRITE: <f1> COLOR 4.
ELSE.
WRITE: <f1> COLOR 2.
ENDIF.
ENDIF.
UNASSIGN <f1>.
ENDLOOP.
ENDLOOP.
END-OF-SELECTION.
END-OF-SELECTION.
AT USER-COMMAND.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'SAVE'.
IF sl_update = 'X'.
CLEAR: sl_step,
sl_status,
sl_subrc,
<fs_wtab>,
d_stat,
m_stat,
max_len.
REFRESH <fs_itd>.
REFRESH <fs_itm>.
DO.
IF sl_status <> 0.
EXIT.
ENDIF.
ADD 1 TO sl_step.
IF sl_subrc <> 0.
EXIT.
ENDIF.
CLEAR ss_step.
CLEAR ss_act.
READ LINE sl_step
FIELD VALUE ss_act INTO f_value.
sl_subrc = sy-subrc.
IF f_value(1) EQ 'D' OR f_value(1) = 'd'.
ss_step = 1. "Delete
ELSEIF f_value(1) EQ 'M' OR f_value(1) = 'm'.
ss_step = 2. "Modify
ELSE.
CLEAR ss_step.
ENDIF.
CHECK sy-lisel(3) = '0Z '.
IF ss_step GT 0.
CLEAR sline.
sline = sy-lisel+5(250).
max_len = 250.
CHECK sline(check_len) <> ' '.
LOOP AT tfield_attr.
CONCATENATE itabname '-' tfield_attr-fieldname
INTO tab_field.
ASSIGN (tab_field) TO <f1>.
IF tfield_attr-fieldname = 'MANDT'.
<f1> = sy-mandt.
ELSE.
CLEAR f_value.
IF max_len LT tfield_attr-outputlen.
max_len = 255.
ADD 1 TO sl_step.
READ LINE sl_step.
sline = sy-lisel.
ENDIF.
f_value = sline(tfield_attr-outputlen).
max_len = max_len - tfield_attr-outputlen - 1.
IF tfield_attr-inttype = 'D'.
IF f_value CO ' 0./-'.
CLEAR sl_datum.
<f1> = sl_datum.
ELSE.
CALL FUNCTION 'CONVERT_DATE_INPUT'
EXPORTING
input = f_value
plausibility_check = 'X'
IMPORTING
output = sl_datum
EXCEPTIONS
plausibility_check_failed = 1
wrong_format_in_input = 2
OTHERS = 3.
IF sy-subrc = 0.
<f1> = sl_datum.
ELSE.
text = 'Invalid Date'.
sl_status = 1.
EXIT.
ENDIF.
ENDIF.
ELSEIF tfield_attr-inttype = 'T'.
IF f_value CO ' 0:'.
CLEAR sl_uzeit.
<f1> = sl_uzeit.
ELSE.
CALL FUNCTION 'CONVERT_TIME_INPUT'
EXPORTING
input = f_value
plausibility_check = 'X'
IMPORTING
output = sl_uzeit
EXCEPTIONS
plausibility_check_failed = 1
wrong_format_in_input = 2
OTHERS = 3.
IF sy-subrc = 0.
<f1> = sl_uzeit.
ELSE.
text = 'Invalid Time'.
sl_status = 1.
EXIT.
ENDIF.
ENDIF.
ELSEIF tfield_attr-inttype = 'C'.
TRANSLATE f_value TO UPPER CASE.
<f1> = f_value.
ELSE.
TRANSLATE f_value USING ', '.
CONDENSE f_value NO-GAPS.
TRY.
<f1> = f_value.
CATCH cx_root INTO ref_ptr.
text = ref_ptr->get_text( ).
sl_status = 1.
EXIT.
ENDTRY.
ENDIF.
SHIFT sline BY tfield_attr-outputlen PLACES.
SHIFT sline LEFT.
ENDIF.
UNASSIGN <f1>.
ENDLOOP.
IF sl_status = 0.
CASE ss_step.
WHEN 1. "Delete
ADD 1 TO d_stat.
APPEND <fs_wtab> TO <fs_itd>.
WHEN 2. "Modify
ADD 1 TO m_stat.
APPEND <fs_wtab> TO <fs_itm>.
ENDCASE.
ENDIF.
ENDIF.
ENDDO.
IF sl_status = 0.
IF d_stat IS NOT INITIAL.
slchar = d_stat.
CONCATENATE 'Deleted -' slchar 'record.' INTO text
SEPARATED BY space.
DELETE (tabname) FROM TABLE <fs_itd>.
ENDIF.
IF m_stat IS NOT INITIAL.
slchar = m_stat.
CONCATENATE text 'Modified -' slchar 'record.' INTO text
SEPARATED BY space.
MODIFY (tabname) FROM TABLE <fs_itm>.
ENDIF.
IF d_stat IS INITIAL AND m_stat IS INITIAL.
MESSAGE 'No changes were done' TYPE 'S'.
ELSE.
MESSAGE text TYPE 'S'.
ENDIF.
LEAVE.
ELSE.
MESSAGE text TYPE 'I'.
EXIT.
ENDIF.
ELSE.
LEAVE.
ENDIF.
ENDCASE.
*--END--
Below is Function for a Dynamic Selection Screen
FUNCTION zstan_selections.
""Local interface:
*" IMPORTING
*" VALUE(TABNAME) LIKE DD02L-TABNAME DEFAULT 'ZSCARE'
*" EXPORTING
*" VALUE(DS_CLAUSES) TYPE RSDS_WHERE
*" EXCEPTIONS
*" TABLE_NOT_VALID
*" OTHER_ERROR
DATA texpr TYPE rsds_texpr.
DATA twhere TYPE rsds_twhere.
DATA trange TYPE rsds_trange.
DATA BEGIN OF qcat. "Selections View for
INCLUDE STRUCTURE rsdsqcat. "Free Selectoptions
DATA END OF qcat.
DATA BEGIN OF tabs OCCURS 10.
INCLUDE STRUCTURE rsdstabs.
DATA END OF tabs.
DATA BEGIN OF fields OCCURS 10.
INCLUDE STRUCTURE rsdsfields.
DATA END OF fields.
DATA BEGIN OF efields OCCURS 10.
INCLUDE STRUCTURE rsdsfields.
DATA END OF efields.
DATA selid LIKE rsdynsel-selid.
DATA actnum LIKE sy-tfill.
DATA title LIKE sy-title VALUE 'Selection Screen'.
DATA: maxnum LIKE sy-subrc VALUE '69'.
CLEAR tabs.
tabs-prim_tab = tabname.
COLLECT tabs.
DATA: position LIKE dd03l-position.
DATA: keyflag LIKE dd03l-keyflag.
CLEAR fields.
fields-tablename = tabname.
fields-sign = 'I'.
DATA: step LIKE sy-subrc.
SELECT fieldname keyflag position
INTO (fields-fieldname, keyflag, position)
FROM dd03l
WHERE tabname = tabname
AND fieldname NOT LIKE '.INCLU%'
AND datatype NE 'CLNT'
ORDER BY position.
ADD 1 TO step.
CHECK step LE maxnum.
IF keyflag <> 'X'.
efields = fields.
APPEND efields.
ENDIF.
APPEND fields.
ENDSELECT.
IF sy-subrc <> 0.
RAISE table_not_valid.
ENDIF.
CALL FUNCTION 'FREE_SELECTIONS_INIT'
EXPORTING
expressions = texpr
kind = 'F'
IMPORTING
selection_id = selid
expressions = texpr
where_clauses = twhere
field_ranges = trange
number_of_active_fields = actnum
TABLES
tables_tab = tabs
fields_tab = fields
fields_not_selected = efields
EXCEPTIONS
fields_incomplete = 01
fields_no_join = 02
field_not_found = 03
no_tables = 04
table_not_found = 05
expression_not_supported = 06
incorrect_expression = 07
illegal_kind = 08
area_not_found = 09
inconsistent_area = 10
kind_f_no_fields_left = 11
kind_f_no_fields = 12
too_many_fields = 13.
IF sy-subrc = 0.
CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
EXPORTING
selection_id = selid
title = title
IMPORTING
where_clauses = twhere
expressions = texpr
field_ranges = trange
number_of_active_fields = actnum
TABLES
fields_tab = fields
EXCEPTIONS
internal_error = 01
no_action = 02
no_fields_selected = 03
no_tables_selected = 04
selid_not_found = 05.
IF sy-subrc = 0.
CLEAR ds_clauses.
MOVE tabname TO ds_clauses-tablename.
READ TABLE twhere WITH KEY ds_clauses-tablename INTO ds_clauses.
IF sy-subrc <> 0.
RAISE other_error.
ENDIF.
ELSE.
RAISE other_error.
ENDIF.
ELSE.
RAISE other_error.
ENDIF.
ENDFUNCTION.
Regards,
Shiva -
HI
i want to populate a filecatlogu, i have dtaa in the itab as
A B C
1 2 3
4 5 6
BUT IN MY OUTPUT DATA is coming as
ABC 123 456
THE CODE I HAVE written to build a filedcalaogue i have written as
data: count type i,count1 type i." intial value 0.
*Build a field catalog dynamically.
LOOP AT i_bdclog1 INTO wg_bdclog1.
* SLIS Catalog
wa_fieldcat1_slis-row_pos = count.
wa_fieldcat1_slis-col_pos = count1.
wa_fieldcat1_slis-fieldname = wg_bdclog1-content.
wa_fieldcat1_slis-seltext_l = wg_bdclog1-content.
wa_fieldcat1_slis-outputlen = 50.
APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.
CLEAR wa_fieldcat1_slis.
count = count + 1.
count1 = count1 + 1.
ENDLOOP.
ENDFORM.
wg_bdclog1-content consist of the data A B C
1 2 3
4 5 6
but still while printing its coming as mentioned above.
i am using REUSE_ALV_BLOCK_LIST_APPEND
Edited by: swarnali_IBM on Aug 20, 2009 11:16 AMhi,
Have you used REUSE_ALV_BLOCK_LIST_DISPLAY??This fm displays the list with data appended by the fm REUSE_ALV_BLOCK_LIST_APPEND
Regards,
Srilatha -
Hi,
How can we build field catalog dynamically??
Regards,
ABC XYZTry this..
LOOP AT it_mandt WHERE mandt IN s_mandt.
CONCATENATE 'CLNT' it_mandt INTO wa_fieldcatalog-fieldname.
wa_fieldcatalog-inttype = 'NUMC'.
wa_fieldcatalog-outputlen = '14'.
wa_fieldcatalog-reptext = it_mandt.
wa_fieldcatalog-seltext = it_mandt.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR :wa_fieldcatalog ,it_mandt.
ENDLOOP. -
Field catalog & internal table are not mutually convertible
Hi friends,
please help me for this problem, actually i m trying to display three alv reports from the three buttond i have given on my first basic report. its working fine till first & getting the data into the internal table for the second also. but when coming to the field catalog for the second report its giving syntax error as my "field catalog and internal table are not mutually convertible'".i have tried by giving different fieldcatalog also but its giving the same problem.please help for this & try to give an example if u can. Thanks a lot.
Regards
PankajThis is my code :
TABLES: PLAF,
MARA,
MAKT,
AFPO,
T023T,
VSAUFK,
T006A,
MBEW,
ZCDR_D.
Type Pools for ALV *************************
TYPE-POOLS: SLIS,
ABAP.
KKBLO.
DATA DECLARATION. ****************************
DATA: FLAG TYPE I,
FLAG1 TYPE I,
FLAG2 TYPE I,
FLAG3 TYPE I,
FLAG4 TYPE I,
FLAG5 TYPE I.
********Declaration for field catalog
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV,
WA_SUBT LIKE SLIS_EV_SUBTOTAL_TEXT,
IT_EVENTS TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
LAYOUT1 TYPE SLIS_LAYOUT_ALV,
IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV,
WA_SUBT LIKE SLIS_EV_SUBTOTAL_TEXT,
IT_EVENTS TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
WA_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV,
LAYOUT2 TYPE SLIS_LAYOUT_ALV,
IT_FIELDCAT2 TYPE SLIS_T_FIELDCAT_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV,
WA_SUBT LIKE SLIS_EV_SUBTOTAL_TEXT,
IT_EVENTS TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
WA_FIELDCAT2 TYPE SLIS_FIELDCAT_ALV,
LAYOUT3 TYPE SLIS_LAYOUT_ALV,
IT_FIELDCAT3 TYPE SLIS_T_FIELDCAT_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV,
WA_SUBT LIKE SLIS_EV_SUBTOTAL_TEXT,
IT_EVENTS TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
WA_FIELDCAT3 TYPE SLIS_FIELDCAT_ALV.
TYPES DECLARATION. ****************************
TYPES: BEGIN OF TY_MARA,
MATNR LIKE MARA-MATNR, " Material Number
MATKL LIKE MARA-MATKL, " Material Group
END OF TY_MARA.
TYPES: BEGIN OF TY_PLAF,
PERTR LIKE PLAF-PERTR, " Date
PLNUM LIKE PLAF-PLNUM, " Planned Order Number
MATNR LIKE PLAF-MATNR, " Material number
PLWRK LIKE PLAF-PLWRK, " Plant
KDAUF LIKE PLAF-KDAUF, " Sales Order Number
KDPOS LIKE PLAF-KDPOS, " SO Line Item
END OF TY_PLAF.
TYPES: BEGIN OF TY_MAKT,
MATNR LIKE PLAF-MATNR, " Material Number
MAKTX LIKE MAKT-MAKTX, " Material Description
END OF TY_MAKT.
TYPES: BEGIN OF TY_AFPO,
PLNUM LIKE AFPO-PLNUM, " Planned Order Number
MATNR LIKE AFPO-MATNR, " Material Number
KDAUF LIKE AFPO-KDAUF, " Sales Order Number
KDPOS LIKE AFPO-KDPOS, " SO Line Item
AUFNR LIKE AFPO-AUFNR, " Production Order
STRMP LIKE AFPO-STRMP,
DWERK LIKE AFPO-DWERK,
END OF TY_AFPO.
TYPES: BEGIN OF TY_ZCDR_D,
MANDT LIKE ZCDR_D-MANDT, " Client
CBNO LIKE ZCDR_D-CBNO, " Customs Book Number
PLNUM LIKE ZCDR_D-PLNUM, " Planned Order Number
MATNR LIKE ZCDR_D-MATNR, " Material Number
MAKTX LIKE ZCDR_D-MAKTX, " Material Description
KDAUF like ZCDR_D-KDAUF, " Sales Order Number
KDPOS like ZCDR_D-KDPOS, " SO Line Item
AUFNR LIKE ZCDR_D-AUFNR, " Production Order
END OF TY_ZCDR_D.
TYPES: BEGIN OF TY_VSAUFK,
INACT LIKE VSAUFK-INACT, " Status Indicator
END OF TY_VSAUFK.
TYPES: BEGIN OF TY_PLAF_MAKT,
CBNO LIKE ZCDR_D-CBNO, " Customs Book Number
PLNUM LIKE PLAF-PLNUM, " Planned Order Number
CHK TYPE C, " Check Box
MATNR LIKE PLAF-MATNR, " Material Number
MAKTX LIKE MAKT-MAKTX, " Material Description
KDAUF LIKE PLAF-KDAUF, " Sales Order Number
KDPOS LIKE PLAF-KDPOS, " SO Line Item
AUFNR LIKE AFPO-AUFNR, " Production Order
END OF TY_PLAF_MAKT.
TYPES: BEGIN OF TY_HELP_ITEM,
CBNO TYPE ZCDR_D-CBNO, " Customs Book Number
PLNUM LIKE ZCDR_D-PLNUM, " Planned Order Number
MATNR LIKE ZCDR_D-MATNR, " Material Number
MAKTX LIKE ZCDR_D-MAKTX, " Material Description
KDAUF LIKE ZCDR_D-KDAUF, " Sales Order Number
KDPOS LIKE ZCDR_D-KDPOS, " SO Line Item
AUFNR LIKE ZCDR_D-AUFNR, " Production Order
END OF TY_HELP_ITEM.
WORK AREA ******************************
DATA: WA_MARA TYPE TY_MARA,
WA_PLAF TYPE TY_PLAF,
WA_MAKT TYPE TY_MAKT,
WA_AFPO TYPE TY_AFPO,
WA_ZCDR_D TYPE TY_ZCDR_D,
WA_VSAUFK TYPE TY_VSAUFK,
WA_PLAF_MAKT TYPE TY_PLAF_MAKT,
WA_HELP_ITEM TYPE TY_HELP_ITEM.
INTERNAL TABLES ****************************
DATA: IT_MARA TYPE TABLE OF TY_MARA,
IT_PLAF TYPE TABLE OF TY_PLAF,
IT_MAKT TYPE TABLE OF TY_MAKT,
IT_AFPO TYPE TABLE OF TY_AFPO,
IT_ZCDR_D TYPE TABLE OF TY_ZCDR_D,
IT_VSAUFK TYPE TABLE OF TY_VSAUFK,
IT_PLAF_MAKT TYPE TABLE OF TY_PLAF_MAKT,
IT_HELP_ITEM TYPE TABLE OF TY_HELP_ITEM.
*it_events TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY
*WITH HEADER LINE INITIAL SIZE 0.
TYPES: BEGIN OF TY_BOM,
MATMK LIKE STPOX-MATMK,
MTNRV LIKE ZCDR_D-MATNR,
IDNRK LIKE STPOX-IDNRK,
MNGLG LIKE STPOX-MNGLG,
MMEIN LIKE STPOX-MMEIN,
VPRSV LIKE STPOX-VPRSV,
UPRICE LIKE MBEW-STPRS,
TPRICE LIKE MBEW-STPRS,
END OF TY_BOM,
BEGIN OF TY_QUAN,
MATMK LIKE STPOX-MATMK,
MTNRV LIKE ZCDR_D-MATNR,
IDNRK LIKE STPOX-IDNRK,
MNGLG LIKE STPOX-MNGLG,
MMEIN LIKE STPOX-MMEIN,
UPRICE LIKE MBEW-STPRS,
TPRICE LIKE MBEW-STPRS,
END OF TY_QUAN,
BEGIN OF TY_T023T,
MATKL LIKE T023T-MATKL,
WGBEZ LIKE T023T-WGBEZ,
END OF TY_T023T,
BEGIN OF TY_T006A,
MMEIN LIKE T006A-MSEHI,
MSEHT LIKE T006A-MSEHT,
END OF TY_T006A,
BEGIN OF TY_IMP_FINAL,
SNO TYPE SY-INDEX,
HSCODE LIKE ZHSCODE-HSCODE,
WGBEZ TYPE T023T-WGBEZ,
SPEC(20) TYPE C,
MNGLG LIKE STPOX-MNGLG,
MSEHT LIKE T006A-MSEHT,
CNTRY(13) TYPE C,
UPRICE TYPE P LENGTH 16 DECIMALS 2,
TPRICE TYPE P LENGTH 16 DECIMALS 2,
CURRCODE TYPE C LENGTH 5,
END OF TY_IMP_FINAL,
BEGIN OF TY_MBEW,
MATNR LIKE MBEW-MATNR,
VPRSV LIKE MBEW-VPRSV,
STPRS LIKE MBEW-STPRS,
VERPR LIKE MBEW-VERPR,
END OF TY_MBEW.
DATA: WA_BOM TYPE TY_BOM,
WA_QUAN TYPE TY_QUAN,
WA_IMP_FINAL TYPE TY_IMP_FINAL,
WA_T023T TYPE TY_T023T,
WA_T006A TYPE TY_T006A,
WA_MBEW TYPE TY_MBEW.
DATA: IT_BOM TYPE TABLE OF TY_BOM,
IT_QUAN TYPE TABLE OF TY_QUAN,
IT_IMP_FINAL TYPE TABLE OF TY_IMP_FINAL,
IT_MBEW TYPE TABLE OF TY_MBEW.
SELECTION-SCREEN **************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS : PR_CBNO LIKE ZCDR_D-CBNO OBLIGATORY. "Customs Book number
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION **************************
INITIALIZATION.
**PERFORM CLEAR_DATA.
**CLEAR: wa_layout.
*PERFORM set_events USING it_events[].
SELECT OPTION ****************************************
SELECTION-SCREEN : BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS:
SO_PERTR for PLAF-PERTR, "----
Date
SO_MATNR for MARA-MATNR, "----
Material
SO_MATKL for MARA-MATKL, "----
Material Group
SO_PLWRK for PLAF-PLWRK OBLIGATORY, "----
Plant
SO_KDAUF for PLAF-KDAUF. "----
Sales Order
SELECTION-SCREEN : END OF BLOCK BLK.
SELECTION SCREEN F4 HELP *********************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR PR_CBNO.
DATA: DYNFIELDS TYPE TABLE OF DYNPREAD WITH HEADER LINE.
DYNFIELDS-FIELDNAME = PR_CBNO.
APPEND DYNFIELDS.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TRANSLATE_TO_UPPER = 'X'
REQUEST = ' '
PERFORM_CONVERSION_EXITS = ' '
PERFORM_INPUT_CONVERSION = ' '
DETERMINE_LOOP_INDEX = ' '
START_SEARCH_IN_CURRENT_SCREEN = ' '
START_SEARCH_IN_MAIN_SCREEN = ' '
START_SEARCH_IN_STACKED_SCREEN = ' '
START_SEARCH_ON_SCR_STACKPOS = ' '
SEARCH_OWN_SUBSCREENS_FIRST = ' '
SEARCHPATH_OF_SUBSCREEN_AREAS = ' '
TABLES
DYNPFIELDS = DYNFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 1
INVALID_DYNPROFIELD = 2
INVALID_DYNPRONAME = 3
INVALID_DYNPRONUMMER = 4
INVALID_REQUEST = 5
NO_FIELDDESCRIPTION = 6
INVALID_PARAMETER = 7
UNDEFIND_ERROR = 8
DOUBLE_CONVERSION = 9
STEPL_NOT_FOUND = 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.
ENDIF.
READ TABLE DYNFIELDS WITH KEY FIELDNAME = 'CBNO'.
PR_CBNO = DYNFIELDS-FIELDVALUE.
SELECT
CBNO
PLNUM
MATNR
MAKTX
KDAUF
KDPOS
AUFNR
FROM ZCDR_D
INTO TABLE IT_HELP_ITEM .
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
RETFIELD = 'CBNO'
PVALKEY = ' '
DYNPPROG = SY-CPROG
DYNPNR = SY-DYNNR
DYNPROFIELD = 'PR_CBNO'
STEPL = 0
WINDOW_TITLE =
VALUE = ' '
VALUE_ORG = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
MARK_TAB =
IMPORTING
USER_RESET =
TABLES
VALUE_TAB = IT_HELP_ITEM
FIELD_TAB =
RETURN_TAB =
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 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.
***********************SELECTION SCREEN VALIDATION.*******************
AT SELECTION-SCREEN ON PR_CBNO.
SELECT SINGLE *
FROM ZCDR_D
WHERE CBNO = PR_CBNO.
IF SY-SUBRC EQ 0.
MESSAGE E000(ZCBR) WITH PR_CBNO.
ENDIF.
AT SELECTION-SCREEN ON SO_PERTR.
IF SO_PERTR IS NOT INITIAL.
SELECT SINGLE *
FROM PLAF
WHERE PERTR IN SO_PERTR.
IF SY-SUBRC NE 0.
MESSAGE W001(ZCBR) WITH SO_PERTR-LOW.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON SO_MATNR.
IF SO_MATNR IS NOT INITIAL.
SELECT SINGLE *
FROM MARA
WHERE MATNR IN SO_MATNR.
IF SY-SUBRC NE 0.
MESSAGE W002(ZCBR) WITH SO_MATNR-LOW.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON SO_MATKL.
IF SO_MATKL IS NOT INITIAL.
SELECT SINGLE *
FROM MARA
WHERE MATKL IN SO_MATKL.
IF SY-SUBRC NE 0.
MESSAGE W003(ZCBR) WITH SO_MATKL-LOW.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON SO_PLWRK.
IF SO_PLWRK IS NOT INITIAL.
SELECT SINGLE * FROM PLAF
WHERE PLWRK IN SO_PLWRK.
IF SY-SUBRC NE 0.
MESSAGE W004(ZCBR) WITH SO_PLWRK-LOW.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON SO_KDAUF.
IF SO_KDAUF IS NOT INITIAL.
SELECT SINGLE * FROM PLAF
WHERE KDAUF IN SO_KDAUF.
IF SY-SUBRC NE 0.
MESSAGE W005(ZCBR) WITH SO_KDAUF-LOW.
ENDIF.
ENDIF.
*********************START-OF-SELECTION.*****************************
START-OF-SELECTION.
IF so_pertr IS NOT INITIAL.
FLAG = 1.
ENDIF.
IF SO_MATNR IS NOT INITIAL.
FLAG1 = 1.
ENDIF.
IF so_matkl IS NOT INITIAL.
FLAG2 = 1.
ENDIF.
IF so_plwrk IS NOT INITIAL.
FLAG3 = 1.
ENDIF.
IF so_kdauf IS NOT INITIAL.
FLAG4 = 1.
ENDIF.
Select data into its internal table from different database tables
SELECT
MATNR
MATKL
MTART
INTO CORRESPONDING FIELDS OF TABLE IT_MARA
FROM MARA
WHERE MTART = 'ZFGS'.
IF FLAG2 NE 0.
DELETE IT_MARA WHERE
NOT ( MATKL IN SO_MATKL )
ENDIF.
IF FLAG1 NE 0.
DELETE IT_MARA WHERE
NOT ( MATNR IN SO_MATNR )
ENDIF.
SELECT
PERTR
PLNUM
MATNR
PLWRK
KDAUF
KDPOS
FROM PLAF
INTO CORRESPONDING FIELDS OF TABLE IT_PLAF
FOR ALL ENTRIES IN IT_MARA
WHERE PLWRK IN SO_PLWRK
AND MATNR = IT_MARA-MATNR.
SELECT
MATNR
PLNUM
AUFNR
KDAUF
KDPOS
STRMP
DWERK
INACT
FROM AFPO
INTO CORRESPONDING FIELDS OF TABLE IT_AFPO
FOR ALL ENTRIES IN IT_MARA
WHERE DWERK IN SO_PLWRK
AND MATNR = IT_MARA-MATNR.
WHERE MATNR = IT_MARA-MATNR
AND STRMP = IT_PLAF-PERTR
AND KDAUF = IT_PLAF-KDAUF
AND DWERK = IT_PLAF-PLWRK.
End of Data selection
Keep only those records which the user wants from his selection screen
IF FLAG NE 0.
DELETE IT_PLAF WHERE
NOT ( PERTR IN SO_PERTR )
DELETE IT_AFPO WHERE
NOT ( STRMP IN SO_PERTR )
ENDIF.
IF FLAG3 NE 0.
DELETE IT_PLAF WHERE
NOT ( PLWRK IN SO_PLWRK )
DELETE IT_AFPO WHERE
NOT ( DWERK IN SO_PLWRK )
ENDIF.
IF FLAG4 NE 0.
DELETE IT_PLAF WHERE
NOT ( KDAUF IN SO_KDAUF )
DELETE IT_AFPO WHERE
NOT ( KDAUF IN SO_KDAUF )
ENDIF.
SELECT
MATNR
MAKTX
FROM MAKT
INTO CORRESPONDING FIELDS OF TABLE IT_MAKT
FOR ALL ENTRIES IN IT_PLAF
WHERE MATNR = IT_PLAF-MATNR
AND SPRAS = 'EN'.
SELECT
FROM ZCDR_D
INTO TABLE IT_ZCDR_D.
Put data into final internal table from different internal tables
LOOP AT IT_MARA INTO WA_MARA.
LOOP AT IT_PLAF INTO WA_PLAF WHERE MATNR = WA_MARA-MATNR.
READ TABLE IT_ZCDR_D
INTO WA_ZCDR_D
WITH KEY PLNUM = WA_PLAF-PLNUM.
IF SY-SUBRC <> 0.
MOVE WA_PLAF-PLNUM TO WA_PLAF_MAKT-PLNUM.
MOVE WA_PLAF-MATNR TO WA_PLAF_MAKT-MATNR.
MOVE WA_PLAF-KDAUF TO WA_PLAF_MAKT-KDAUF.
MOVE WA_PLAF-KDPOS TO WA_PLAF_MAKT-KDPOS.
READ TABLE IT_AFPO INTO WA_AFPO WITH KEY PLNUM = WA_PLAF-PLNUM.
MOVE WA_AFPO-AUFNR TO WA_PLAF_MAKT-AUFNR.
SELECT
SINGLE * FROM VSAUFK
INTO TABLE IT_VSAUFK
WHERE AUFNR = WA_AFPO-AUFNR
AND STAT = 'I0012'.
IF SY-SUBRC <> 0.
MOVE WA_AFPO-AUFNR TO IT_PLAF_MAKT-AUFNR.
ELSE.
CHECK IT_VSAUFK-INACT = 'X'.
MOVE WA_AFPO-AUFNR TO IT_PLAF_MAKT-AUFNR.
ENDIF.
ENDLOOP.
READ TABLE IT_MAKT
INTO WA_MAKT
WITH KEY MATNR = WA_MARA-MATNR.
MOVE WA_MAKT-MAKTX TO WA_PLAF_MAKT-MAKTX.
APPEND WA_PLAF_MAKT TO IT_PLAF_MAKT.
CLEAR WA_PLAF_MAKT.
ENDIF.
ENDLOOP.
ENDLOOP.
LOOP AT IT_PLAF_MAKT .
LOOP AT IT_MARA INTO WA_MARA.
LOOP AT IT_PLAF INTO WA_PLAF WHERE MATNR = WA_MARA-MATNR.
LOOP AT IT_AFPO INTO WA_AFPO WHERE MATNR = WA_MARA-MATNR.
READ TABLE IT_ZCDR_D
INTO WA_ZCDR_D
WITH KEY PLNUM = WA_AFPO-PLNUM.
IF SY-SUBRC <> 0.
LOOP AT IT_AFPO INTO WA_AFPO.
WHERE MATNR IN SO_MATNR
AND STRMP = SO_PERTR
AND PLNUM IN SO_PLNUM
AND KDAUF IN SO_-KDAUF
AND MATKL IN SO_MATKL.
SELECT
SINGLE INACT FROM VSAUFK
INTO WA_VSAUFK
WHERE AUFNR = WA_AFPO-AUFNR
AND STAT = 'I0012'.
IF SY-SUBRC <> 0.
WA_PLAF_MAKT-PLNUM = WA_AFPO-PLNUM.
WA_PLAF_MAKT-KDAUF = WA_AFPO-KDAUF.
WA_PLAF_MAKT-KDPOS = WA_AFPO-KDPOS.
WA_PLAF_MAKT-MATNR = WA_AFPO-MATNR.
WA_PLAF_MAKT-AUFNR = WA_AFPO-AUFNR.
READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_AFPO-MATNR.
WA_PLAF_MAKT-MAKTX = WA_MAKT-MAKTX.
APPEND WA_PLAF_MAKT TO IT_PLAF_MAKT .
APPEND WA_AFPO TO IT_PLAF_MAKT.
MOVE WA_AFPO-AUFNR TO IT_PLAF_MAKT-AUFNR.
ELSE.
CHECK WA_VSAUFK-INACT = 'X'.
WA_PLAF_MAKT-PLNUM = WA_AFPO-PLNUM.
WA_PLAF_MAKT-KDAUF = WA_AFPO-KDAUF.
WA_PLAF_MAKT-KDPOS = WA_AFPO-KDPOS.
WA_PLAF_MAKT-MATNR = WA_AFPO-MATNR.
WA_PLAF_MAKT-AUFNR = WA_AFPO-AUFNR.
READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_AFPO-MATNR.
WA_PLAF_MAKT-MAKTX = WA_MAKT-MAKTX.
APPEND WA_PLAF_MAKT TO IT_PLAF_MAKT .
APPEND WA_AFPO TO IT_PLAF_MAKT.
MOVE WA_AFPO-AUFNR TO IT_PLAF_MAKT-AUFNR.
ENDIF.
ENDIF.
ENDLOOP.
EXIT.
ENDIF.
ENDLOOP.
ENDLOOP.
LOOP AT IT_PLAF_MAKT INTO WA_PLAF_MAKT.
WA_PLAF_MAKT-CBNO = PR_CBNO.
MODIFY IT_PLAF_MAKT FROM WA_PLAF_MAKT TRANSPORTING CBNO.
ENDLOOP.
ENDLOOP.
PERFORM CHANGE_CATALOG.
PERFORM ALV_DISPLAY.
*& Form CHANGE_CATALOG
text
FORM CHANGE_CATALOG.
LAYOUT-ZEBRA = 'X'.
DATA: L_POS TYPE I.
L_POS = L_POS + 1.
WA_FIELDCAT-col_pos = L_POS.
WA_FIELDCAT-SELTEXT_M = 'Planned Order Nos.'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'PLNUM'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-INPUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'Check Box'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-CHECKBOX = 'X'.
WA_FIELDCAT-EDIT = abap_true.
WA_FIELDCAT-FIELDNAME = 'CHK'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-OUTPUTLEN = '12'.
WA_FIELDCAT-SELTEXT_M = 'Material'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-OUTPUTLEN = '35'.
WA_FIELDCAT-SELTEXT_M = 'Material Description'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'MAKTX'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-SELTEXT_M = 'Sales Order Number'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'KDAUF'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-SELTEXT_M = 'S O Line Item'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'KDPOS'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-OUTPUTLEN = '13'.
WA_FIELDCAT-SELTEXT_M = 'Production Order'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'AUFNR'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
*GS_LAYOUT-TOTALS_BEFORE_ITEMS = 'X'.
*data : text like slis_ev_subtotal_text value 'total'.
*gs_layout-subtotals_text = text.
*gs_layout-totals_only = 'X'.
gs_layout-subtotals_text = 'total'.
endform. " CHANGE_CATALOG
*********************event*************************************
*& Form ALV_DISPLAY
text
FORM ALV_DISPLAY.
*data: LC_GLAY TYPE LVC_S_GLAY.
LC_GLAY-EDT_CLL_CB = 'X'.
gs_layout-colwidth_optimize = 'X'.
gs_layout-zebra = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'PLANNED ORDERS'
I_GRID_SETTINGS = LC_GLAY
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'X'
IS_VARIANT =
IT_EVENTS = IT_EVENTS[]
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_IT_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_PLAF_MAKT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH IT_FIELDCAT[].
ENDFORM. "ALV_DISPLAY
*& Form USER_COMMAND
text
-->UCOMM text
-->SELFIELD text
FORM USER_COMMAND
USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
Data: REF1 TYPE REF TO CL_GUI_ALV_GRID.
DATA WA LIKE LINE OF IT_PLAF_MAKT.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF1.
CALL METHOD REF1->CHECK_CHANGED_DATA.
CASE UCOMM.
WHEN '&BACK'.
LEAVE TO SCREEN 0.
WHEN '&EXIT'.
LEAVE TO SCREEN 0.
WHEN '&CANC'.
LEAVE TO SCREEN 0.
WHEN '&SAVE'.
CLEAR IT_ZCDR_D[].
LOOP AT IT_PLAF_MAKT INTO WA_PLAF_MAKT WHERE CHK = 'X'.
CLEAR WA_ZCDR_D.
WA_ZCDR_D-MANDT = SY-MANDT.
WA_ZCDR_D-CBNO = WA_PLAF_MAKT-CBNO.
WA_ZCDR_D-plnum = WA_PLAF_MAKT-PLNUM.
WA_ZCDR_D-MATNR = WA_PLAF_MAKT-MATNR.
WA_ZCDR_D-MAKTX = WA_PLAF_MAKT-MAKTX.
WA_ZCDR_D-KDAUF = WA_PLAF_MAKT-KDAUF.
WA_ZCDR_D-KDPOS = WA_PLAF_MAKT-KDPOS.
WA_ZCDR_D-AUFNR = WA_PLAF_MAKT-AUFNR.
APPEND WA_ZCDR_D to IT_ZCDR_D.
ENDLOOP.
LOOP AT IT_ZCDR_D INTO WA_ZCDR_D.
INSERT ZCDR_D FROM WA_ZCDR_D.
CLEAR WA_ZCDR_D.
ENDLOOP.
IF SY-SUBRC EQ 0.
MESSAGE S021(ZCBR) WITH PR_CBNO.
ENDIF.
IF IT_ZCDR_D IS INITIAL.
MESSAGE 'Select Atleast one Check Box' TYPE 'E' .
ENDIF.
WHEN 'IMPORT_INF'.
PERFORM IMPORT_REPORT.
WHEN 'EXPORT_INF'.
PERFORM EXPORT_REPORT.
WHEN 'UNIT_CONSU'.
PERFORM UNIT_CONSUMPTION.
ENDCASE.
ENDFORM. "USER_COMMAND
FORM set_events USING it_events TYPE slis_t_event.
DATA: x_event TYPE slis_alv_event.
clear x_event.
x_event-name = 'USER_COMMAND'.
x_event-form = 'USER_COMMAND'.
append x_event to it_events.
CLEAR x_event.
call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = IT_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
read table it_events into x_event with key name = slis_ev_user_command.
if sy-subrc = 0.
x_event-form = 'USER_COMMAND'.
modify it_events from x_event index sy-tabix transporting form .
endif.
ENDFORM.
*& Form set_pf_status
text
-->RT_EXTAB text
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'Z_PFSTAT'.
ENDFORM. " set_pf_status
FORM IMPORT_REPORT.
TYPES: BEGIN OF TY_BOM,
MATMK LIKE STPOX-MATMK,
MTNRV LIKE ZCDR_D-MATNR,
IDNRK LIKE STPOX-IDNRK,
MNGLG LIKE STPOX-MNGLG,
MMEIN LIKE STPOX-MMEIN,
VPRSV LIKE STPOX-VPRSV,
UPRICE LIKE MBEW-STPRS,
TPRICE LIKE MBEW-STPRS,
END OF TY_BOM,
BEGIN OF TY_QUAN,
MATMK LIKE STPOX-MATMK,
MTNRV LIKE ZCDR_D-MATNR,
IDNRK LIKE STPOX-IDNRK,
MNGLG LIKE STPOX-MNGLG,
MMEIN LIKE STPOX-MMEIN,
UPRICE LIKE MBEW-STPRS,
TPRICE LIKE MBEW-STPRS,
END OF TY_QUAN,
BEGIN OF TY_T023T,
MATKL LIKE T023T-MATKL,
WGBEZ LIKE T023T-WGBEZ,
END OF TY_T023T,
BEGIN OF TY_T006A,
MMEIN LIKE T006A-MSEHI,
MSEHT LIKE T006A-MSEHT,
END OF TY_T006A,
BEGIN OF TY_IMP_FINAL,
SNO TYPE SY-INDEX,
HSCODE LIKE ZHSCODE-HSCODE,
WGBEZ TYPE T023T-WGBEZ,
SPEC(20) TYPE C,
MNGLG LIKE STPOX-MNGLG,
MSEHT LIKE T006A-MSEHT,
CNTRY(13) TYPE C,
UPRICE TYPE P LENGTH 16 DECIMALS 2,
TPRICE TYPE P LENGTH 16 DECIMALS 2,
CURRCODE TYPE C LENGTH 5,
END OF TY_IMP_FINAL,
BEGIN OF TY_MBEW,
MATNR LIKE MBEW-MATNR,
VPRSV LIKE MBEW-VPRSV,
STPRS LIKE MBEW-STPRS,
VERPR LIKE MBEW-VERPR,
END OF TY_MBEW.
DATA: WA_BOM TYPE TY_BOM,
WA_QUAN TYPE TY_QUAN,
WA_IMP_FINAL TYPE TY_IMP_FINAL,
WA_T023T TYPE TY_T023T,
WA_T006A TYPE TY_T006A,
WA_MBEW TYPE TY_MBEW.
DATA: IT_BOM TYPE TABLE OF TY_BOM,
IT_QUAN TYPE TABLE OF TY_QUAN,
IT_IMP_FINAL TYPE TABLE OF TY_IMP_FINAL,
IT_MBEW TYPE TABLE OF TY_MBEW.
DATA: IT_STPO TYPE STANDARD TABLE OF STPOX,
WA_STPO TYPE STPOX.
SELECT
MATNR
VPRSV
STPRS
VERPR
FROM MBEW
INTO CORRESPONDING FIELDS OF TABLE IT_MBEW.
WHERE MATNR EQ IT_MARA-MATNR. "MBEW
*I_STPO2 TYPE STANDARD TABLE OF STPOX.
LOOP AT IT_PLAF_MAKT INTO WA_PLAF_MAKT WHERE CHK = 'X'.
LOOP AT IT_ZCDR_D INTO WA_ZCDR_D .
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2' -
Field catalog with INCLUDE TYPE
Hi all,
I want to build field catalog for internal table which has INCLUDE TYPE. Can anybody please help me.
Please note,
LVC_FIELDCATALOG_MERGE or REUSE_ALV_FIELDCATALOG_MERGE are not working -- Refer documentation of second FM..
Manual method is out of question, there are lot of tables / structure and i am doing lot of stuff dynamically.
Thanks,
Regards,
MohaiyuddinCannot do it with include.. I had defined all internal table instead of structures..
Maybe you are looking for
-
Does Time Machine replace changed files and delete old files?
I haven't upgraded to Leopard yet, but my son is a NEW CONVERT to the Mac; has uses Dells for years. He has a new Macbook Pro with Leopard. I use SuperDuper! with my Tiger Mini Mac. I don't understand what Time Machine does. Does it continually updat
-
SQL script runs under SQL Devoper, will not run under UNIX, SQLPlus
I have a sql program I developed under the SQL Developer tool and it runs fine. I have ftp'd the sql to the Unix server and I am trying to run the same program under SQL Plus in unix. The program echo's back the line number that is the last line numb
-
Sales order released from Credit block, but Purchase Requistion not created
Hi, In third party sales scenario based on Scheduline Line category configuration purchase requistion creates when the order is created. If order is blocked for credit check then purchase requistion will not be created until order released from credi
-
Cancel Technical Completion of a TECO'd service order through program
Hi All, In IW32 transaction for a service order I need to Cancel the Technical Completion.Menu path is Order>Functions>Complete-->Cancel Technical Completion. How can I do this through program.I tried the FM status_change_intern. But its not working.
-
Hello i bought a new IPAD 2 64 GB 3G ios 4.3.3 when i bought it i notice that its capacity about 59GB then i got trouble in it so i use to restore it and i download the software again from itunes about 614 mb after that it works perfect but the ipad