DISPLAYING -DYNAMIC COLUM IN ALV ??? READ MESSGAE
hi friends ,
Thanks for your reply , here is one question i am displaying my code
in short .. what i want is to display column dynamically using the
field-symbols.... can anybody help me with syntax or code i wil be
thank full to him .i find little code for it on sdn also .
sdn code,
1. Create your field catalog either manually or automatically using the function module, LVC_FIELDCATALOG_MERGE.
Add more rows to the field catalog table (T_FIELDCAT) at run time.
2. Use the field catalog to create a table dynamically using the method below.
DATA: T_OUTPUT TYPE REF TO DATA
FIELD-SYMBOLS: <T_OUTPUT> TYPE TABLE
Call Method CL_ALV_TABLE_CREATE->CREATE_DYNAMIC_TABLE
Exporting
IT_FIELDCATALOG = T_FIELDCAT
Importing
EP_TABLE = T_OUTPUT
ASSIGN T_OUTPUT->* TO <T_OUTPUT>.
Now the field symbol <T_OUTPUT> is pointing to an output table of the structure that contains the fields which were determined at runtime.
Now fill this table with the data and pass <T_OUTPUT> to the method SET_TABLE_FOR_FIRST_DISPLAY and the ALV grid should show the data properly.
here is my code."""" IAM USING SCREEN..HERE
after the start of selection .
LOOP AT i_vat.
IF i_vat-mwskz IS NOT INITIAL.
'CALCULATE_TAX_ITEM'
i_itaxcom-bukrs = i_vat-bukrs.
i_itaxcom-waers = i_vat-waers.
i_itaxcom-kposn = i_vat-ebelp.
i_itaxcom-mwskz = i_vat-mwskz.
i_itaxcom-wrbtr = i_vat-netwr.
i_itaxcom-matnr = i_vat-matnr.
i_itaxcom-mglme = i_vat-menge.
i_itaxcom-werks = i_vat-werks.
i_itaxcom-bldat = i_vat-bedat.
i_itaxcom-budat = i_vat-bedat.
i_itaxcom-lifnr = i_vat-lifnr.
i_itaxcom-shkzg = 'H'.
i_itaxcom-xmwst = 'X'.
i_itaxcom-matkl = i_vat-matkl.
i_itaxcom-meins = i_vat-meins.
i_itaxcom-mtart = i_vat-mtart.
i_itaxcom-land1 = 'IN'.
i_itaxcom-ebeln = zxekko-ebeln.
i_itaxcom-ebelp = <fs>-ebelp.
*end of correction 20.10.2004
REFRESH i_otaxcom.
CALL FUNCTION 'CALCULATE_TAX_ITEM'
EXPORTING
i_taxcom = i_itaxcom
TABLES
t_xkomv = i_otaxcom.
LOOP AT i_otaxcom WHERE kposn = i_vat-ebelp. "kposn - condition item number
READ TABLE i_tcode WITH KEY ebeln = i_vat-ebeln
ebelp = i_vat-ebelp
kschl = i_otaxcom-kschl.
IF sy-subrc <> 0.
IF i_otaxcom-kwert <> 0.
i_tcode-kschl = i_otaxcom-kschl.
tcode-ebeln = i_vat-ebeln.
i_tcode-ebelp = i_vat-ebelp.
i_tcode-kschl = i_otaxcom-kschl.
i_tcode-kwert = i_otaxcom-kwert.
APPEND i_tcode.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
LOOP AT i_vat.
count1 = 1.
LOOP AT i_tcode WHERE ebeln = i_vat-ebeln AND ebelp = i_vat-ebelp.
Alv_fieldname+5 = count1.
ASSIGN COMPONENT Alv_fieldname OF STRUCTURE i_vat
TO <fs_value>.
IF sy-subrc EQ 0.
<fs_value> = i_tcode-kwert.
ENDIF.
count1 = count1 + 1.
MODIFY i_vat.
ENDLOOP.
ENDLOOP.
SELECT DISTINCT kschl
vtext
INTO CORRESPONDING FIELDS OF TABLE i_tcode1
FROM t685t
FOR ALL ENTRIES IN i_tcode
WHERE kschl = i_tcode-kschl AND
kappl = 'TX' AND
spras = sy-langu.
count1 = 1..
LOOP AT i_tcode1
READ TABLE i_tcode WITH KEY kschl = i_tcode1-kschl .
IF sy-subrc = 0.
CONCATENATE 'BAVAL' count1 INTO fld_name.
i_tcode1-text = fld_name.
MODIFY i_tcode1.
count1 = count1 + 1.
ENDIF.
ENDLOOP.
PERFORM sort_build USING gt_sort[].
PERFORM layout_init USING gs_layout.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'EBELN' 'C' 'Documnet No'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'EBELP' 'C' 'Line Item'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'WERKS' 'C' 'Plant'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'LIFNR' 'C' 'Vendor'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME1' 'C' 'Vendor Name '.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MATNR' 'C' 'Material'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MAKTX' 'C' 'Material Description'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MENGE' 'QUAN' 'Order Quantity '.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NETPR' 'CURR' 'Price Rate'.
OR DYNAMIC DISLPLAY.
BUT I WANT IN FIELD SYMBOL WAY
LOOP AT i_tcode1.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] i_tcode1-text 'QUAN' i_tcode1-vtext.
ENDLOOP
Hi Farukh,
Regarding ALv u can find full details in this below link.This should help u better.
http://help.sap.com/saphelp_erp2005/helpdata/en/b8/d84f59aac911d295e300a0c9306433/frameset.htm
In this goto ABAP List viwer to c all the details and functions of ALv.
Regards,
Nagarajan.
Similar Messages
-
Display dynamic columns in ALV
Hi All,
I have a requirement in which I have develop a report displaying material master basic data and classification data. The basic data I am getting from MARA and MAKT tables. And for classification data I am getting the class maintained from each material from tables INOB,KSSK and from KLAH, then I am getting the characteristics and its values by calling BAPI u2018BAPI_OBJCL_GETDETAILu2019 for each material .
Now I have to prepare ALV having column name for basic data (would be static) and characteristic name (would be dynamic, and I have to display characteristics values under it, for each material ).
For example: if material u2018CHWOJA4u2019 has 2 characteristics as u2018country (value u2018Franceu2019)u2019 and u2018creation season(value u2018Decu2019)u2019 and second material u2018E50480u2019 has 3 characteristics as u2018Abacus (value u2018yesu2019)u2019 ,u2018country (value u2018Indiau2019)u2019 and u2018 season(value Jank)u2019 , the ALV output would be :
Material Number; Material description; Base Unit of Measure;Material Group; Abacus; Country;season
CHWOJA4; JACKET;PC;Z05; ; France;Dec
E50480;BRAZIL REAL;PC;Z06; yes; India;Jan
In short, my last column of the ALV would be the characteristic name and the content would be the char. value.
Can you please suggest some ways to achieve this? A quick reply would be highly appreciated!
Thanks,
VanithaIdea here is to have many fields for characterstic values in your output internal table.
For eg.
types : Begin of ty_mara,
matnr type matnr_d,
mtext type mktxt,
char1 type string,
char2 type string,
char20 type string.
Check for all the materials which has the maximum characterstic values. So, say for a material, there are 12 characterstics values and that is the maximum compared to anyother materials. Then in the field catalog hide the columns related to charactertics CHAR13 onwards till CHAR20.
Note : I have assumed char20 as the max., which you can alter based on your scenario.
Regards
Ranganath -
Need ALV LIST for displaying Dynamic Internal Tables
Hi Guys,
I have some thing like 2 Dynamic internal tables.
Say 1st Internal table will be filled based on some condition.
say 2nd table will be filled based on some condition.
When appending the 1st Internal table, if that internal table is filled it creates another internal table of same kind and continues so on until some condition.
In the same way when appending the 2nd Internal table, if that internal table is filled it creates another internal table of same kind and continues so on until some condition.
My requirement is I need to display all these Internal tables in the output.
The output should look something like
1st Internal Table
some gap
2nd Internal Table
some gap
so on...................
Is there any standard ALV List, to display all these Internal Tables in such a way.
Thanks,
Prasad.Hi.
One thing more here is code which get 10 records from 2 tables and then show them in ALV.
first when u execute it will show data from ist table.
when u go back (F3) then it will sow data from 2nd table.
But if u want to show both ALV on the same screen then u will have to use screen programin and using class u will have to create container and then have to do it.
But as i above mentioned. that sample code is as below.
REPORT ztn_test LINE-COUNT 100.
data: itab_ref type ref to data.
data: hstr type lvc_title.
data: tabname like DD02T-TABNAME.
tabname = 'MARA'. " First Table
create data itab_ref type standard table of (tabname).
field-symbols: <itab> type standard table.
assign itab_ref->* to <itab>.
select * UP TO 10 ROWS from (tabname) into corresponding fields of table <itab>.
perform showalv.
tabname = 'KNA1'. " 2nd Table
create data itab_ref type standard table of (tabname).
"field-symbols: <itab> type standard table.
assign itab_ref->* to <itab>.
select * UP TO 10 ROWS from (tabname) into corresponding fields of table <itab>.
perform showalv.
form showalv.
" to show that data in alv
type-pools: slis.
data: myalv type ref to cl_gui_alv_grid, "ALV Grid
fieldcat type slis_t_fieldcat_alv, "Field Catalog Table
ls_fcat type slis_fieldcat_alv, "Line of Field catalog.
ls_heading type slis_listheader, "Line of Heading.
layout type slis_layout_alv, "layout of ALV for Heading and Logo.
event type slis_t_event, "Event Raising to Display Heading.
event_str type slis_alv_event. "Event String.
type-pools: slis.
data: heading type slis_t_listheader. "List Heading.
if heading[] is initial.
ls_heading-typ = 'H'.
ls_heading-info = 'HR: Master Data Change History'.
append ls_heading to heading.
endif.
* ls_heading-typ = 'A'.
* ls_heading-info = ''.
* APPEND ls_heading TO heading.
* ALV DISPLAY *
*******Making Layout of ALV
layout-zebra = 'X'.
layout-colwidth_optimize = 'X'.
*Calling function to raise event to display heading and icon above ALV
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = event[]
* 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.
******calling TOP_OF_PAGE Event
read table event with key name = 'TOP_OF_PAGE' into event_str.
if sy-subrc = 0.
move: 'TOP_OF_PAGE' to event_str-form.
modify event from event_str index sy-tabix.
endif.
**** Now use this Fuction to display ALV without any Screen Programming.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = 'SAPLZFSL_HR_UTILS' "sy-cprog
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
i_structure_name = tabname
* I_BACKGROUND_ID = ' '
i_grid_title = hstr "Heading of ALV Grid.
* I_GRID_SETTINGS =
is_layout = layout
* it_fieldcat = fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
i_default = 'X'
i_save = 'X'
* IS_VARIANT =
it_events = event[]
* 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_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = <itab>
* 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.
endform. -
Hello experts,
is it possible to call an ALV via ( class cl_salv or fm REUSE_ALV_GRID_DISPLAY) with a dynamic table?
This dynamic table has for example one fix column for the material number and dynamic colums for additional data.
One material has 1 additional column, the other material has two additional columns.
So i need an ALV with 3 columns material add_data1 add_data2 (add_data2 of material one is empty this is ok).
To build an itab which can handle this is possible i know.Hello Benjamin,
Maybe you already found a solution for this, but if not (or for others looking for a solution), here is a sample program that creates, fills, and displays a dynamic table:
report ztpar_dynamic_salv.
parameters: p_colnr type i default 3.
start-of-selection.
perform execute.
form execute.
data t_table type ref to data.
** create dynamic table
perform create_dynamic_table using p_colnr
changing t_table.
** fill dynamic table
perform fill_dynamic_table changing t_table.
** display dynamic table
perform display_table using t_table.
endform.
form create_dynamic_table using colnr type i
changing table type ref to data.
data: lo_field type ref to cl_abap_typedescr,
lo_struct type ref to cl_abap_structdescr,
lo_table type ref to cl_abap_tabledescr.
data: t_comp type cl_abap_structdescr=>component_table,
l_comp like line of t_comp.
lo_field ?= cl_abap_typedescr=>describe_by_name( 'CHAR10' ).
do p_colnr times.
move sy-index to l_comp-name.
concatenate 'COLUMN' l_comp-name into l_comp-name.
condense l_comp-name no-gaps.
l_comp-type ?= lo_field.
append l_comp to t_comp.
enddo.
lo_struct = cl_abap_structdescr=>create( p_components = t_comp p_strict = space ).
lo_table = cl_abap_tabledescr=>create( lo_struct ).
create data table type handle lo_table.
endform.
form fill_dynamic_table changing table type ref to data.
field-symbols: <fs_table> type standard table,
<fs_line> type any,
<fs_field> type any.
assign table->* to <fs_table>.
do 5 times.
append initial line to <fs_table> assigning <fs_line>.
do.
assign component sy-index of structure <fs_line> to <fs_field>.
if sy-subrc ne 0.
exit.
endif.
<fs_field> = sy-index.
enddo.
enddo.
endform.
form display_table using i_table type ref to data.
data lo_alv type ref to cl_salv_table.
field-symbols <fs_tab> type any table.
assign i_table->* to <fs_tab>.
try.
cl_salv_table=>factory(
importing
r_salv_table = lo_alv
changing
t_table = <fs_tab> ).
catch cx_salv_msg.
message 'Cannot display result!' type 'E'.
endtry.
lo_alv->display( ).
endform.
Best regards,
Tanguy -
Dear Experts,
I want to display dynamc columns in ALV, how it possible.
venkeycreate dynamic internal table from field catalog i m sending u some sample code hope it will help u.
FORM create_dynamic_itab.
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat[]
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM. -
Hi All,
I need to display three tables using alv.
i have used one alv component in my application.
In my context i have three nodes ( for three tables )
when i am trying to map one node of my component control to 'DATA' of alv component
its working fine. i am getting the data of one table .
Now , my problem is for the remainig two tables . how these two nodes are mapped for the same alv 'DATA' attribute of alv component.
Whether i need to create two more alv components or Is there any possible to dynamic mapping ?
Thanks and Regards,
sravan.Hi Sravan,
Now , my problem is for the remainig two tables . how these two nodes are mapped for the same alv 'DATA' attribute of alv component
You cann't map the multiple context nodes to the DATA node of interface controller.You have to declare 3 component usages.
or
you want to set the map the dynamically then use this code.
data:l_ref_interfacecontroller type ref to iwci_salv_wd_table.
l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
l_ref_interfacecontroller->set_data( lo_node ). -
Dynamical Call of ALV - No data update
Hi,
I tried to use use the ALV dynamically. With dynamically I mean that I that I have diffrent data structures, depending what was selected by the user. The first call of the program is always correct. The data is displayed correctly. But when the data structure is changing, the ALV display is not updated. For a better understanding I post a extract of my coding:
<b>1. Creation of Container</b>
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'PARENT_CONT'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc <> 0.
ASSERT 1 = 2.
ENDIF.
<b>2.Creation of splitter container</b>
CREATE OBJECT splitter
EXPORTING
parent = g_custom_container
rows = 2
columns = 2
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ASSERT 1 = 2.
ENDIF.
container_2 = splitter->get_container(
row = 1
column = 2 ).
<b>3.Dynamic Creation of alv object</b>
CREATE OBJECT go_grid
EXPORTING
i_parent = container_2.
<b>4. Get Fieldcatalogue</b>
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = lv_structure_name
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ASSERT 1 = 2.
ENDIF.
<b>5. Set table for first display</b>
CALL METHOD go_grid->set_table_for_first_display
* EXPORTING
* i_structure_name = lv_structure_name
CHANGING
it_fieldcatalog = lt_fieldcat
it_outtab = <lt_out_data>.
CALL METHOD ls_alv_ref-alv_ref->refresh_table_display.
CALL METHOD cl_gui_cfw=>flush.
Perhaps someone could help.....
Best Regards, EdgarHello Edgar
The following sample report <b>ZUS_SDN_TWO_ALV_GRIDS_8</b> shows how to solve your problem. Please note that for the sake of simplicity I replaced the tree containing the structure names with an ALV list. However, the switch between the different structures is triggered by the <b>DOUBLE_CLICK</b> event.
I like to add that the integration of the first displayed ALV list (DD02L) into GT_OUTTAB is not really elegant. In addition, with <b>$TMP</b> I marked a problematic part of the coding with respect to your requirement to have the right layout for each displayed ALV list:
If you have a <b>fixed </b>assignment of <i>tabname -> 4-digit handle</i> then it is ok. I my sample report the layouts only work if you select the tabnames in the very same order.
Before showing the entire coding I describe crucial parts of the coding:
[code]TYPES: BEGIN OF ty_s_outtab.
TYPES: tabname TYPE tabname.
TYPES: layout TYPE lvc_s_layo.
TYPES: variant TYPE disvariant.
TYPES: fcat TYPE lvc_t_fcat.
TYPES: data TYPE REF TO data.
TYPES: END OF ty_s_outtab.[/code]
Every time a new structure is selected the corresponding ALV data are stored as new record in GT_OUTTAB which is of line type TY_S_OUTTAB.
[code] READ TABLE gt_outtab INTO gs_outtab INDEX 2.
ASSIGN gs_outtab-fcat TO <gt_fcat>.
ASSIGN gs_outtab-data->* TO <gt_outtab>.[/code]
Since the ALV list data and the fieldcatalog are fully dynamic I use global field-symbols for these data.
[code]&----
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
SET TITLEBAR 'xxx'.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = gs_outtab-tabname
is_layout = gs_outtab-layout
is_variant = gs_outtab-variant
i_save = 'A'
CHANGING
it_outtab = <gt_outtab>
it_fieldcatalog = <gt_fcat>
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT[/code]
The second ALV list which displays the table records is always newly displayed in the PBO module.
In the event handler method <b>HANDLE_DOUBLE_CLICK</b> we need to do two things:
- store the current fieldcatalog back to GT_OUTTAB
- store the name of the new selected table/structure -> trigger PAI
In routine <b>HANDLE_DB_CLICK</b> we create a new entry for GT_OUTTAB if it does not yet exist. Next we select this entry and display it again as second ALV list.
[code]
*& Report ZUS_SDN_TWO_ALV_GRIDS_8
*& Description: Display two ALV lists in splitter container (left/right)
*& Left ALV list contains DB table names,
*& right ALV list displays entries of selected DB table
*& SDN thread: Dynamical Call of ALV - No data update
*& Link: https:||Dynamical Call of ALV - No data update
*& Screen '0100' contains no elements.
*& ok_code -> assigned to GD_OKCODE
*& Flow logic:
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
REPORT zus_sdn_two_alv_grids_8.
TYPE-POOLS: abap.
DATA:
gd_repid TYPE syst-repid,
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_cell_left TYPE REF TO cl_gui_container,
go_cell_right TYPE REF TO cl_gui_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid,
gs_layout TYPE lvc_s_layo.
TYPES: BEGIN OF ty_s_outtab.
TYPES: tabname TYPE tabname.
TYPES: layout TYPE lvc_s_layo.
TYPES: variant TYPE disvariant.
TYPES: fcat TYPE lvc_t_fcat.
TYPES: data TYPE REF TO data.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA:
gt_dd02l TYPE STANDARD TABLE OF dd02l,
gs_outtab TYPE ty_s_outtab,
gt_outtab TYPE ty_t_outtab.
FIELD-SYMBOLS:
<gt_fcat> TYPE lvc_t_fcat,
<gt_outtab> TYPE table.
CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
md_tabname_selected TYPE tabname READ-ONLY.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
define local data
DATA:
ls_dd02l TYPE dd02l,
ls_outtab TYPE ty_s_outtab.
CHECK ( sender = go_grid1 ).
READ TABLE gt_dd02l INTO ls_dd02l INDEX e_row-index.
" Store data of currently displayed ALV list (except for DD02L)
IF ( md_tabname_selected = space ).
ELSE.
READ TABLE gt_outtab INTO ls_outtab
WITH KEY tabname = md_tabname_selected. " old
CALL METHOD go_grid2->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = ls_outtab-fcat.
MODIFY gt_outtab FROM ls_outtab INDEX syst-tabix.
ENDIF.
md_tabname_selected = ls_dd02l-tabname. " new selected DB table
Triggers PAI of the dynpro with the specified ok-code
cl_gui_cfw=>set_new_ok_code( 'HANDLE_DB_CLICK' ). " not 4.6c
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'HANDLE_DB_CLICK'
IMPORTING
RC =
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
gd_repid = syst-repid.
SELECT * FROM dd02l INTO TABLE gt_dd02l
WHERE tabname LIKE 'KN%1' OR
tabname LIKE 'LF%1' OR
tabname LIKE 'VB%' OR
tabname LIKE 'MAR%' OR
tabname LIKE 'E07%'
AND tabclass = 'TRANSP'. " transparent table
SORT gt_dd02l BY tabname.
PERFORM init_controls.
PERFORM add_first_table.
Set event handler
SET HANDLER:
lcl_eventhandler=>handle_double_click FOR go_grid1.
READ TABLE gt_outtab INTO gs_outtab INDEX 1.
Display data
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = gs_outtab-tabname
is_layout = gs_outtab-layout
CHANGING
it_outtab = gt_dd02l
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE gt_outtab INTO gs_outtab INDEX 2.
ASSIGN gs_outtab-fcat TO <gt_fcat>.
ASSIGN gs_outtab-data->* TO <gt_outtab>.
NOTE: method called in PBO module
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = gs_outtab-tabname
is_layout = gs_outtab-layout
is_variant = gs_outtab-variant
i_save = 'A'
CHANGING
it_outtab = <gt_outtab>
it_fieldcatalog = <gt_fcat>
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
Flow logic of dynpro (does not contain any dynpro elements):
*PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
SET TITLEBAR 'xxx'.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = gs_outtab-tabname
is_layout = gs_outtab-layout
is_variant = gs_outtab-variant
i_save = 'A'
CHANGING
it_outtab = <gt_outtab>
it_fieldcatalog = <gt_fcat>
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
User has pushed button "Display Details"
WHEN 'HANDLE_DB_CLICK'.
PERFORM handle_db_click.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form HANDLE_DB_CLICK
text
--> p1 text
<-- p2 text
FORM handle_db_click.
define local data
DATA:
ld_handle(4) TYPE n,
ls_outtab TYPE ty_s_outtab.
READ TABLE gt_outtab INTO ls_outtab
WITH KEY tabname = lcl_eventhandler=>md_tabname_selected.
IF ( syst-subrc NE 0 ).
CLEAR: ls_outtab.
ls_outtab-tabname = lcl_eventhandler=>md_tabname_selected.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
i_structure_name = ls_outtab-tabname
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = ls_outtab-fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 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.
CREATE DATA ls_outtab-data TYPE TABLE OF (ls_outtab-tabname).
ASSIGN ls_outtab-data->* TO <gt_outtab>.
SELECT * FROM (ls_outtab-tabname) UP TO 50 ROWS
INTO TABLE <gt_outtab>.
ls_outtab-layout-no_toolbar = abap_false.
ls_outtab-layout-zebra = abap_true.
ls_outtab-layout-smalltitle = abap_true.
CONCATENATE ls_outtab-tabname ':'
INTO ls_outtab-layout-grid_title.
CONCATENATE ls_outtab-layout-grid_title 'Table Records'
INTO ls_outtab-layout-grid_title
SEPARATED BY space.
ls_outtab-variant-report = gd_repid.
DESCRIBE TABLE gt_outtab.
ld_handle = syst-tfill + 1.
WRITE ld_handle TO ls_outtab-variant-handle. " $TMP: Problem!!!
APPEND ls_outtab TO gt_outtab.
ENDIF.
" NOTE: read into GLOBAL variable gs_outtab !!!!
READ TABLE gt_outtab INTO gs_outtab
WITH KEY tabname = lcl_eventhandler=>md_tabname_selected.
ASSIGN gs_outtab-fcat TO <gt_fcat>.
ASSIGN gs_outtab-data->* TO <gt_outtab>.
ENDFORM. " HANDLE_DB_CLICK
*& Form INIT_CONTROLS
text
--> p1 text
<-- p2 text
FORM init_controls .
Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_docking->set_extension
EXPORTING
extension = 99999 " full-size screen
EXCEPTIONS
cntl_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.
Create splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 1
columns = 2
NO_AUTODEF_PROGID_DYNNR =
NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 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.
Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_left.
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = go_cell_right.
CALL METHOD go_splitter->set_column_mode
EXPORTING
mode = cl_gui_splitter_container=>mode_relative
IMPORTING
RESULT =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 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.
CALL METHOD go_splitter->set_column_width
EXPORTING
id = 1
width = 25
IMPORTING
RESULT =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 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.
CALL METHOD go_splitter->set_column_sash
EXPORTING
id = 1
type = cl_gui_splitter_container=>type_movable
value = cl_gui_splitter_container=>false
IMPORTING
RESULT =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 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.
Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_left
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT go_grid2
EXPORTING
i_parent = go_cell_right
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " INIT_CONTROLS
*& Form ADD_FIRST_TABLE
text
--> p1 text
<-- p2 text
FORM add_first_table .
define local data
DATA:
ls_outtab TYPE ty_s_outtab.
ls_outtab-tabname = 'DD02L'.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
i_structure_name = ls_outtab-tabname
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = ls_outtab-fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 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.
GET REFERENCE OF gt_dd02l INTO ls_outtab-data.
ls_outtab-layout-no_toolbar = abap_false.
ls_outtab-layout-zebra = abap_true.
ls_outtab-layout-smalltitle = abap_true.
CONCATENATE ls_outtab-tabname ':'
INTO ls_outtab-layout-grid_title.
CONCATENATE ls_outtab-layout-grid_title 'Table Records'
INTO ls_outtab-layout-grid_title
SEPARATED BY space.
ls_outtab-variant-report = gd_repid.
ls_outtab-variant-handle = '0002'.
INSERT ls_outtab INTO gt_outtab INDEX 1.
ls_outtab-layout-no_toolbar = abap_true.
ls_outtab-layout-zebra = abap_true.
ls_outtab-layout-smalltitle = abap_true.
ls_outtab-layout-grid_title = 'DB Tables'.
ls_outtab-variant-report = gd_repid.
ls_outtab-variant-handle = '0001'.
DELETE ls_outtab-fcat WHERE ( fieldname NE 'TABNAME' ).
INSERT ls_outtab INTO gt_outtab INDEX 1.
ENDFORM. " ADD_FIRST_TABLE[/code]
Regards,
Uwe -
Displaying special characters in ALV report.
Hi Experts,
Can we display special characters in ALV reports? Special characters such as tick mark.(Like in character map(Font Bookshelf Symbol 7) of windows ).
I tried with icons in ALV report, I was able to display tick icon in the ALV report, but when we export the report in to a excel, the icons comes in as Hexadecimal code.
Can any we display special characters like tick in ALV report or display the icons in excel aswell?
I will be gratefull for the <urgency reduced by moderator> response.
Regards,
Sharath.
Edited by: Thomas Zloch on May 10, 2011 10:26 AMSharath,
I think it is possible to do so.
Please check this link.
http://www.sapfans.com/forums/viewtopic.php?f=13&t=322569
Thanks,
Guru. -
How to display dynamic signature in Smartforms?
Hi,
Someone could help me in displaying dynamic signatures in SmartForms?. The signature is an attached file to the document. I already have the binary file but I don't know how to display this as an image in the Smartforms.
Thanks in advance,
Oliver
Message was edited by: Oliver Vera
Message was edited by: Oliver VeraPlease give me the reply.
I have an image content in one internal table.I want to display that image in the smartforms.
plaese please. -
How to display the fields in ALV Output without using Field catalog?
How to display the fields in ALV Output without using Field catalog?
Could you pls tell me the coding?
Akshitha.Hi,
u mean without building field catalog. is it? I that case, we can use the FM REUSE_ALV_FIELDCATALOG_MERGE.
data: itab type table of mara.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = itab
CHANGING
ct_fieldcat = lt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*Pass that field catalog into the fillowing FM
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_grid_title = 'REPORTING'
is_layout = gt_layout
it_fieldcat = lt_fieldcat[]
tables
t_outtab = itab. -
Problem in display of text in ALV report
Dear experts,
I am working on a MM Report in which I need to display Material Basic data text maintained in MM01,02 Tcodes through ALV report.
I have declared a string type variable for the Basic data text in the Final Internal Table.
For reading the Standard text I am using Read_Text FM, from which I am looping the Text internal table and concatenating it into
String variable.
What I notice is all the content beyond 255 chars is not getting displayed, Even when the ALV report is downloaded to Excel file.
Can you suggest some approach to over come this issue.
Regards,
MurthyHi,
Use the below code
Data : lt_content TYPE TABLE OF tline,
lw_content TYPE tline.
Data : lt_text Type Table of solisti1,
lw_text TYPE solisti1.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = lv_id
language = tdspras
name = lv_name
object = lv_object
archive_handle = 0
local_cat = ' '
TABLES
lines = lt_content
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
loop at lt_content into lw_content.
lw_text-line = lw_content-tdline.
APPEND lw_text TO lt_text.
CLEAR: lw_content, lw_text.
endloop.
Now your whole text is in "lt_text".
Regards,
Avish Mittal -
Display Traffic Lights in ALV TREE
Hi,
I have to display traffic light in ALV tree but i am not able to find out what parameter i should pass like in ALV grid where we can set is_layout (BCALV_GRID_04).
Thanks in advance.
Regards,
HarshHi,
Please take a look at my code below. Hope it suits your requirement.
P.S. Please award points if it helps...
*& Report ZMM_R_PO_TO_IPURCH_XI
*& PROGRAM TYPE : Report
*& RICEF ID :
*& TITLE : ZMM_R_PO_TO_IPURCH_XI
*& SAP Module : MM
*& CREATION DATE : 02/06/2008
*& AUTHOR : Aris Hidalgo
*& DESIGNER : Aris Hidalgo
*& DESCRIPTION :
*$**********************************************************************
*$ CHANGE HISTORY
*$----------------------------------------------------------------------
*$ DATE | T-Num | Description | Reference
** | | |
*$**********************************************************************
REPORT zmm_r_po_to_ipurch_xi
NO STANDARD PAGE HEADING
MESSAGE-ID zmm.
* Data Dictionary Table/s *
TABLES: edidc.
* SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_credat FOR edidc-credat OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: rb_sum RADIOBUTTON GROUP grp1,
rb_det RADIOBUTTON GROUP grp1.
SELECTION-SCREEN END OF BLOCK b2.
*/ CLASS DEFINITION/S /*
* CLASS lcl_data_def DEFINITION
CLASS lcl_data_def DEFINITION ABSTRACT.
PUBLIC SECTION.
TYPES: BEGIN OF t_edidc,
docnum TYPE edidc-docnum,
docrel TYPE edidc-docrel,
status TYPE edidc-status,
doctyp TYPE edidc-doctyp,
direct TYPE edidc-direct,
rcvpor TYPE edidc-rcvpor,
rcvprt TYPE edidc-rcvprt,
rcvprn TYPE edidc-rcvprn,
rcvsad TYPE edidc-rcvsad,
sndpor TYPE edidc-sndpor,
sndprt TYPE edidc-sndprt,
sndprn TYPE edidc-sndprn,
sndsad TYPE edidc-sndsad,
credat TYPE edidc-credat,
cretim TYPE edidc-cretim,
mestyp TYPE edidc-mestyp,
idoctp TYPE edidc-idoctp,
END OF t_edidc.
TYPES: BEGIN OF t_output,
exception TYPE char1,
ebeln TYPE ekko-ebeln,
lifnr TYPE lfa1-lifnr,
name1 TYPE lfa1-name1,
credat TYPE edidc-credat,
cretim TYPE edidc-cretim,
END OF t_output.
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekko-ebeln,
lifnr TYPE ekko-lifnr,
END OF t_ekko.
TYPES: BEGIN OF t_lfa1,
lifnr TYPE lfa1-lifnr,
name1 TYPE lfa1-name1,
END OF t_lfa1.
DATA: gt_edidc TYPE STANDARD TABLE OF t_edidc,
gt_output TYPE STANDARD TABLE OF t_output,
wa_output LIKE LINE OF gt_output,
gt_ekko TYPE HASHED TABLE OF t_ekko
WITH UNIQUE KEY ebeln,
gt_lfa1 TYPE HASHED TABLE OF t_lfa1
WITH UNIQUE KEY lifnr.
ENDCLASS. "lcl_data_def DEFINITION
CLASS lcl_alv_routines DEFINITION DEFERRED.
CLASS lcl_handle_events DEFINITION DEFERRED.
* CLASS lcl_get_data DEFINITION
CLASS lcl_get_data DEFINITION INHERITING FROM lcl_data_def.
PUBLIC SECTION.
METHODS: get_idocs,
read_idocs,
process_data
IMPORTING
im_docnum TYPE edidc-docnum.
PRIVATE SECTION.
CONSTANTS: lc_mestyp TYPE edidc-mestyp VALUE 'ZMARKETSITE_PURCHASE_ORDER',
lc_idoctp TYPE edidc-idoctp VALUE 'ZMARKETSITE_PURCHASE_ORDER01',
lc_segnam TYPE edid4-segnam VALUE 'ZMARKETSITE_ORDER_HEADER1'.
CONSTANTS: lc_red TYPE i VALUE 1,
lc_yellow TYPE i VALUE 2,
lc_green TYPE i VALUE 3.
DATA: lv_stat_message TYPE bdidocattr-message,
o_lcl_alv_routines TYPE REF TO lcl_alv_routines.
DATA: ls_idoc_control TYPE edidc,
lv_tot_data_recs TYPE sy-dbcnt, "#EC NEEDED
lv_tot_status_recs TYPE sy-dbcnt. "#EC NEEDED
DATA: lt_edids TYPE STANDARD TABLE OF edids,
lt_edidd TYPE STANDARD TABLE OF edidd.
ENDCLASS. "lcl_get_data DEFINITION
* CLASS lcl_alv_routines DEFINITION
CLASS lcl_alv_routines DEFINITION INHERITING FROM lcl_get_data.
PUBLIC SECTION.
DATA: lcl_table TYPE REF TO cl_salv_table,
lcl_container TYPE REF TO cl_gui_custom_container,
lcl_handle_events TYPE REF TO lcl_handle_events,
lcl_columns TYPE REF TO cl_salv_columns_table,
lcl_column TYPE REF TO cl_salv_column_table,
lcl_events2 TYPE REF TO cl_salv_events_table,
lcl_display_settings TYPE REF TO cl_salv_display_settings,
lcl_functions TYPE REF TO cl_salv_functions_list,
lcl_display TYPE REF TO cl_salv_display_settings,
lcl_aggregations TYPE REF TO cl_salv_aggregations,
lcl_sorts TYPE REF TO cl_salv_sorts,
lcl_content TYPE REF TO cl_salv_form_element,
lcl_header TYPE REF TO cl_salv_form_header_info,
ls_color TYPE lvc_s_colo.
DATA: lcl_grid TYPE REF TO cl_salv_form_layout_grid,
lcl_grid_1 TYPE REF TO cl_salv_form_layout_grid,
lcl_grid_2 TYPE REF TO cl_salv_form_layout_grid,
lcl_label TYPE REF TO cl_salv_form_label,"#EC NEEDED
lcl_text TYPE REF TO cl_salv_form_text,
gt_t247 TYPE STANDARD TABLE OF t247,
wa_t247 LIKE LINE OF gt_t247,
lv_text TYPE string.
METHODS: display_data
IMPORTING
im_output LIKE gt_output,
display_top_of_page.
PRIVATE SECTION.
DATA: lv_string TYPE string,
lv_date1 TYPE c LENGTH 10,
lv_time TYPE c LENGTH 10,
lv_title TYPE string.
ENDCLASS. "lcl_alv_routines DEFINITION
* CLASS lcl_handle_events DEFINITION
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
*/ IMPLEMENTATION/S /*
* CLASS lcl_get_data IMPLEMENTATION
CLASS lcl_get_data IMPLEMENTATION.
* METHOD get_idocs
METHOD get_idocs.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
text = text-p01.
SELECT docnum docrel status doctyp
direct rcvpor rcvprt rcvprn
rcvsad sndpor sndprt sndprn
sndsad credat cretim mestyp
idoctp
FROM edidc
INTO TABLE gt_edidc
WHERE mestyp = lc_mestyp
AND idoctp = lc_idoctp
AND credat IN s_credat.
IF gt_edidc[] IS NOT INITIAL.
* Get IDOC details
CALL METHOD me->read_idocs.
ENDIF.
ENDMETHOD. "get_idocs
* METHOD read_idocs
METHOD read_idocs.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
text = text-p02.
FIELD-SYMBOLS: <fs_edidc> LIKE LINE OF gt_edidc,
<fs_output> LIKE LINE OF gt_output,
<fs_ekko> LIKE LINE OF gt_ekko,
<fs_lfa1> LIKE LINE OF gt_lfa1.
LOOP AT gt_edidc ASSIGNING <fs_edidc>.
CLEAR ls_idoc_control.
REFRESH: lt_edids, lt_edidd.
* Get status text of IDOC
CALL FUNCTION 'IDOC_GET_MESSAGE_ATTRIBUTE'
EXPORTING
idoc_number = <fs_edidc>-docnum
IMPORTING
idoc_message = lv_stat_message.
* Get IDOC details
CALL FUNCTION 'IDOC_READ_COMPLETELY'
EXPORTING
document_number = <fs_edidc>-docnum
IMPORTING
idoc_control = ls_idoc_control
number_of_data_records = lv_tot_data_recs
number_of_status_records = lv_tot_status_recs
TABLES
int_edids = lt_edids
int_edidd = lt_edidd
EXCEPTIONS
document_not_exist = 1
document_number_invalid = 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.
* Pass data to output table
CALL METHOD me->process_data
EXPORTING
im_docnum = <fs_edidc>-docnum.
ENDLOOP.
DELETE gt_output WHERE ebeln IS INITIAL.
IF gt_output[] IS NOT INITIAL.
* Get vendor for fetched POs
SELECT ebeln lifnr
FROM ekko
INTO TABLE gt_ekko
FOR ALL ENTRIES IN gt_output
WHERE ebeln = gt_output-ebeln.
IF gt_ekko[] IS NOT INITIAL.
* Get name of vendors
SELECT lifnr name1
FROM lfa1
INTO TABLE gt_lfa1
FOR ALL ENTRIES IN gt_ekko
WHERE lifnr = gt_ekko-lifnr.
ENDIF.
* Pass vendor details to output table
LOOP AT gt_output ASSIGNING <fs_output>.
READ TABLE gt_ekko ASSIGNING <fs_ekko>
WITH TABLE KEY ebeln = <fs_output>-ebeln.
IF sy-subrc = 0.
READ TABLE gt_lfa1 ASSIGNING <fs_lfa1>
WITH TABLE KEY lifnr = <fs_ekko>-lifnr.
IF sy-subrc = 0.
<fs_output>-lifnr = <fs_lfa1>-lifnr.
<fs_output>-name1 = <fs_lfa1>-name1.
ENDIF.
ENDIF.
ENDLOOP.
CREATE OBJECT o_lcl_alv_routines.
CALL METHOD o_lcl_alv_routines->display_data
EXPORTING
im_output = gt_output[].
ENDIF.
ENDMETHOD. "read_idocs
* METHOD process_data
METHOD process_data.
FIELD-SYMBOLS: <fs_edidd> LIKE LINE OF lt_edidd.
IF lv_stat_message CP 'ok' OR
lv_stat_message CP 'positive'.
wa_output-exception = lc_green.
ELSEIF lv_stat_message CP 'error' OR
lv_stat_message CP 'negative'.
wa_output-exception = lc_red.
ELSE.
wa_output-exception = lc_yellow.
ENDIF.
READ TABLE lt_edidd ASSIGNING <fs_edidd>
WITH KEY docnum = im_docnum
segnam = lc_segnam.
IF sy-subrc = 0.
wa_output-ebeln = <fs_edidd>-sdata+0(10).
ENDIF.
wa_output-credat = ls_idoc_control-credat.
wa_output-cretim = ls_idoc_control-cretim.
APPEND wa_output TO gt_output.
CLEAR wa_output.
ENDMETHOD. "process_data
ENDCLASS. "lcl_get_data IMPLEMENTATION
* CLASS lcl_alv_routines IMPLEMENTATION
CLASS lcl_alv_routines IMPLEMENTATION.
* METHOD display_data
METHOD display_data.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = 0
text = text-p03.
gt_output[] = im_output[].
TRY.
cl_salv_table=>factory(
EXPORTING
list_display = ''
IMPORTING
r_salv_table = lcl_table
CHANGING
t_table = gt_output ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
lcl_functions = lcl_table->get_functions( ).
* Set all standard ALV functions
lcl_functions->set_all( abap_true ).
lcl_columns = lcl_table->get_columns( ).
lcl_columns->set_optimize( '' ).
* Set display to striped pattern
lcl_display = lcl_table->get_display_settings( ).
lcl_display->set_striped_pattern( cl_salv_display_settings=>true ).
*/Sort columns
TRY.
lcl_sorts = lcl_table->get_sorts( ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
lcl_sorts->set_group_active( ).
TRY.
lcl_sorts->add_sort(
columnname = 'EBELN'
subtotal = '' ).
CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER
ENDTRY.
*/Set column names
TRY.
lcl_columns->set_exception_column( 'EXCEPTION' ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'EXCEPTION' ).
lcl_column->set_short_text( text-h01 ).
lcl_column->set_medium_text( text-h01 ).
lcl_column->set_long_text( text-h01 ).
lcl_column->set_output_length( '6' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'EBELN' ).
lcl_column->set_short_text( text-h02 ).
lcl_column->set_medium_text( text-h02 ).
lcl_column->set_long_text( text-h02 ).
lcl_column->set_output_length( '9' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'LIFNR' ).
* lcl_column->set_short_text( text-h03 ).
lcl_column->set_medium_text( text-h03 ).
lcl_column->set_long_text( text-h03 ).
lcl_column->set_output_length( '11' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'NAME1' ).
* lcl_column->set_short_text( text-h04 ).
* lcl_column->set_medium_text( text-h04 ).
lcl_column->set_long_text( text-h04 ).
lcl_column->set_output_length( '30' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'CREDAT' ).
* lcl_column->set_short_text( text-h05 ).
* lcl_column->set_medium_text( text-h05 ).
lcl_column->set_long_text( text-h05 ).
lcl_column->set_output_length( '13' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'CRETIM' ).
* lcl_column->set_short_text( text-h06 ).
* lcl_column->set_medium_text( text-h06 ).
lcl_column->set_long_text( text-h06 ).
lcl_column->set_output_length( '13' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
*/Set aggregations
* TRY.
* lcl_aggregations = lcl_table->get_aggregations( ).
* CATCH cx_salv_not_found. "#EC NO_HANDLER
* ENDTRY.
* TRY.
* lcl_aggregations->add_aggregation( '' ).
* CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER
* ENDTRY.
*/Hide columns
* TRY.
* lcl_column ?= lcl_columns->get_column( 'DESCRIPT' ).
* lcl_column->set_visible( if_salv_c_bool_sap=>false ).
* CATCH cx_salv_not_found. "#EC NO_HANDLER
* ENDTRY.
*/Display top of page
CALL METHOD me->display_top_of_page.
lcl_table->set_top_of_list( lcl_content ).
*/Handle ALV events
lcl_events2 = lcl_table->get_event( ).
CREATE OBJECT lcl_handle_events.
SET HANDLER lcl_handle_events->on_link_click FOR lcl_events2.
lcl_display_settings = lcl_table->get_display_settings( ).
lcl_table->display( ).
ENDMETHOD. "display_data
* METHOD display_top_of_page
METHOD display_top_of_page.
CREATE OBJECT lcl_grid.
lv_title = text-t01.
lcl_grid->create_header_information(
row = 1
column = 1
text = lv_title
tooltip = lv_title ).
lcl_grid->add_row( ).
lcl_grid_1 = lcl_grid->create_grid(
row = 3
column = 1 ).
CLEAR lv_string.
CONCATENATE: sy-datum+4(2) '/' sy-datum+6(2) '/' sy-datum+0(4)
INTO lv_date1.
CONCATENATE: text-t02 lv_date1
INTO lv_string
SEPARATED BY space.
lcl_label = lcl_grid_1->create_label(
row = 1
column = 1
text = lv_string
tooltip = lv_string ).
CLEAR lv_string.
CONCATENATE: sy-uzeit+0(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2)
INTO lv_time.
CONCATENATE: text-t03 lv_time
INTO lv_string
SEPARATED BY space.
lcl_label = lcl_grid_1->create_label(
row = 2
column = 1
text = lv_string
tooltip = lv_string ).
lcl_content = lcl_grid.
ENDMETHOD. "display_top_of_page
ENDCLASS. "lcl_alv_routines IMPLEMENTATION
* CLASS lcl_handle_events IMPLEMENTATION
CLASS lcl_handle_events IMPLEMENTATION.
* METHOD on_link_click
METHOD on_link_click.
ENDMETHOD. "on_link_click
ENDCLASS. "lcl_handle_events IMPLEMENTATION
* START-OF-SELECTION *
START-OF-SELECTION.
DATA: o_lcl_get_data TYPE REF TO lcl_get_data.
CREATE OBJECT o_lcl_get_data.
CALL METHOD o_lcl_get_data->get_idocs. -
Dynamic selection in ALV report
Hi Guru's
I have cpoied a standatrd program(RFBILA00) into Z-program.
I need to display the profit centre from dynamic selection in ALV header output when profit centre is selected.If not no need to display it.
Please do the needful.
Thanks,
Sunil.hi,
Refer to the link,
http://www.abapcode.info/2007/06/dynamic-selection-on-alv-at-run-time.html
This may help you.
Regards
Sumit Aagrwal -
hai
How to display a column in alv(Container) in dynamic manner at runtime.
specify the code if u have.
thx in advance.Hi,
Herewith i am sending the mdoel report for the DYNAMIC DEMO.
Kindly go through it the following.
REPORT YMS_DYNAMICDEMO
NO STANDARD PAGE HEADING
MESSAGE-ID zcs_c2c_001.
type-pools : abap.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.
start-of-selection.
perform get_structure.
perform create_dynamic_itab.
perform get_data.
perform write_out.
form get_structure.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform.
form create_dynamic_itab.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = ifc
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
endform.
form get_data.
Select Data from table.
select * into table <dyn_table>
from (p_table).
endform.
form write_out.
Write out data from table.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index
of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
endform.
Thanks,
Shankar -
How to display dynamic header title in the report?
I have a req to display dynamic header title in the report.
When a id is entered in the prompt text, it will display the user data based on that user_id.
so similarly....the header title should vary each time when you select different user_id.
How can we implement this?>
Zack H wrote:
> Lazaro,
>
> It depends on what you want displayed in the heading for each id.
> Please elaborate.
>
> Thanks,
> Zack H.
Zack..I have several projects listed under several project id's...
so when a user selects project id 00164 then it should display something like "Project document for Jon Doe"
again when the user selects project id as 00192 then it should display something like "project document for Zimmerman"
Did you get it??
Maybe you are looking for
-
Multiple threads block each other, but its not a deadlock!
I have recently upgraded to Berkeley 2.4.16/DB 4.6.21 on Linux 2.6.9-68.9.ELsmp #1 SMP 2008 x86_64 GNU/Linux Right away I noticed that when I run two threads, one doing a putDocument, another doing a query, they get stuck, as if they were deadlocked,
-
Import Manager 'Error 5611520 - Error Saving Key Mapping'
I am using CREDITOR_EXTRACT in R/3 to send Vendor IDoc to XI and use CREMDM04 type. XI generates an XML file that I load into MDM using a client that is set up for Inbound/Outbound. The key mappings have been turned on for the Vendor repository. In
-
Problems copying files to a SMB share.
Hello, Having some odd issues since moving to 10.6. It appears to be a combination of two problems. We are in a PC based Active Directory environment. The Mac is bound to the AD and has a Mobile account configured. The problem is with copying files t
-
File to IDOC Scenario using BPM
Hi Experts, I am working on file-Bapi-Idoc scenario using BPM. I have two conditions 1. If the Sonumber is populated then need trigger an Bapi_change 2.If the Sonumber is not populated from the file then need to trigger a Bapi_Createfromdat t
-
Two Conditions in If statement
Hi, I wanted to include two condition in a single IF statement. So, i tried below, <?xdofx:if :POH_CANCEL_FLAG='Y' and :POH_PO_TYPE!='RELEASE' then?><?call-template:po_oc?><?end if?> But this is calling the template even if one condition is false. Ca