Column as pushbutton in alv
Hi all,
i want to know the moethod by which we can display a coulumn as pushbutton in alv when we are usingFM Reuse_alv_list_display.. to display ALV...
if possible then give me some sample code
Regards,
Syed
Check This example which shows button in a cell
REPORT ZTESTALV.
type-pools: slis.
*Fieldcatalog
data: it_fieldcat type lvc_t_fcat,
it_fieldcat1 type slis_t_fieldcat_alv..
*For Events
data:it_events type slis_t_event.
data: x_fieldcat type lvc_s_fcat,
x_fieldcat1 type slis_fieldcat_alv.
data:x_layout type lvc_s_layo.
data: begin of it_vbap occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
button(10),
end of it_vbap.
data: ls_outtab like line of it_vbap.
select vbeln
posnr
up to 10 rows
into corresponding fields of table it_vbap
from vbap.
data:l_pos type i value 1.
clear: l_pos.
l_pos = l_pos + 1.
x_fieldcat-seltext = 'Button'.
x_fieldcat-fieldname = 'BUTTON'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-icon = 'X'.
x_fieldcat-col_pos = l_pos.
x_fieldcat-outputlen = '10'.
x_fieldcat-style = x_fieldcat-style bit-xor
cl_gui_alv_grid=>mc_style_button bit-xor
cl_gui_alv_grid=>mc_style_enabled.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-seltext = 'VBELN'.
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = l_pos.
x_fieldcat-edit = 'X'.
x_fieldcat-outputlen = '10'.
x_fieldcat-ref_field = 'VBELN'.
x_fieldcat-ref_table = 'VBAK'.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-seltext = 'POSNR'.
x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = l_pos.
x_fieldcat-outputlen = '5'.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
l_pos = l_pos + 1.
call function 'REUSE_ALV_GRID_DISPLAY_LVC'
exporting
i_callback_program = sy-repid
is_layout_lvc = x_layout
it_fieldcat_lvc = it_fieldcat
tables
t_outtab = it_vbap[]
exceptions
program_error = 1
others = 2.
if sy-subrc eq 0.
endif.
Similar Messages
-
How can I add a pushbutton inside ALV toolbar?
Hi,
This can be included into ALV by defining a GUI and setting that GUI using Set PF Status.
Check the below code for the same,
REPORT ZSPRENH069 NO STANDARD PAGE HEADING.
TYPE-POOLS : SLIS. "Global Type for ALV
T Y P E S *
TYPES:
BEGIN OF TY_VB_AKAP,
VBELN TYPE VBELN_VA, "Sales Document
KUNNR TYPE KUNAG, "Sold-to party
POSNR TYPE POSNR_VA, "Item Number
MATNR TYPE MATNR, "Material Number
PMATN TYPE PMATN, "Pricing Reference Material/Newly Created Material
KWMENG TYPE KWMENG, "Cumulative Order Qty. in Sales Units
VRKME TYPE VRKME, "Sales Unit
NETPR TYPE NETPR, "Net Price
KZWI1 TYPE KZWI1, "Sub Total 1 from pricing procedure for condition
VKAUS TYPE ABRVW, "Usage Indicator
END OF TY_VB_AKAP,
BEGIN OF TY_MARA,
MATNR TYPE MATNR, "Material Number
ZZTECHSPEC TYPE ZTECHSPEC, "Technical Specification
END OF TY_MARA,
BEGIN OF TY_MVKE,
MATNR TYPE MATNR, "Material Number
VKORG TYPE VKORG, "Sales Organization
VTWEG TYPE VTWEG, "Distribution Channel
KONDM TYPE KONDM, "Material Pricing Group
END OF TY_MVKE,
BEGIN OF TY_VBKD,
VBELN TYPE VBELN_VA, "Sales Document
POSNR TYPE POSNR_VA, "Item Number
BSTKD_E TYPE BSTKD_E, "Used to capture New Material Number
END OF TY_VBKD,
BEGIN OF TY_IHEADER,
SELECT(1) TYPE C, "Check Box
VBELN TYPE VBELN, "Sales Document
KUNNR TYPE KUNAG, "Sold-to Party
END OF TY_IHEADER,
BEGIN OF TY_MESSAGE1,
VKORG TYPE VKORG, "Sales Organization
VTWEG TYPE VTWEG, "Distribution Channel
KUNNR TYPE KUNAG, "Customer number
KONDM TYPE KONDM, "Material pricing group
ZCOUNT(2) TYPE N, "Zcount
MSGTYP(1) TYPE C, "Message type
TEXT(150) TYPE C, "Message text
END OF TY_MESSAGE1,
BEGIN OF TY_MESSAGE2,
VKORG TYPE VKORG, "Sales Organization
VTWEG TYPE VTWEG, "Distribution Channel
KUNNR TYPE KUNAG, "Customer number
MATNR TYPE MATNR, "Material Number
MSGTYP(1) TYPE C, "Message type
TEXT(150) TYPE C, "Message text
END OF TY_MESSAGE2,
BEGIN OF TY_IFINAL,
VBELN TYPE VBELN_VA, "Sales Document
KWMENG TYPE KWMENG, "Cumulative Order Qty. in Sales Units
POSNR TYPE POSNR_VA, "Item Number
KUNNR TYPE KUNAG, "Sold-to party
MATNR TYPE MATNR, "Material Number
VRKME TYPE VRKME, "Sales Unit
KZWI1 TYPE KZWI1, "Sub Total 1 from pricing procedure for condition
VKAUS TYPE ABRVW, "Usage Indicator
ZZTECHSPEC TYPE ZTECHSPEC, "Technical Specification
PMATN TYPE PMATN, "Pricing Reference Material/Newly Created Material
KONDM TYPE KONDM, "Material Pricing Group
END OF TY_IFINAL,
BEGIN OF TY_ACC1,
VBELN TYPE VBELN_VA, "Sales Document
KUNNR TYPE KUNAG, "Sold-to party
KONDM TYPE KONDM, "Material Pricing Group
ZCOUNT(2) TYPE N, "ZCount indicator
KSTBM TYPE KSTBM, "Quantity
VRKME TYPE VRKME, "Sales Unit
ZZTECHSPEC TYPE ZTECHSPEC, "Technical Specification
KZWI1 TYPE KZWI1, "Sub Total 1 from pricing procedure for condition
ERROR(1) TYPE N, "Error Field
END OF TY_ACC1,
BEGIN OF TY_ACC2,
VBELN TYPE VBELN_VA, "Sales Document
KUNNR TYPE KUNAG, "Sold-to party
MATNR TYPE MATNR, "Material Number
KSTBM TYPE KSTBM, "Cumulative Order Qty. in Sales Units
ZZTECHSPEC TYPE ZTECHSPEC, "Technical Specification
VRKME TYPE VRKME, "Sales Unit
KZWI1 TYPE KZWI1, "Sub Total 1 from pricing procedure for condition
ERROR(1) TYPE N, "Error field
END OF TY_ACC2.
D A T A *
Internal Table Declarations
DATA: T_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV, "Fieldcatalog IT
T_EVENTS TYPE SLIS_T_EVENT, "Event IT
T_HEADER TYPE SLIS_T_LISTHEADER, "Header IT
T_VB_AKAP TYPE STANDARD TABLE OF TY_VB_AKAP, "To hold records from VBAK & VBAP Table
T_MARA TYPE STANDARD TABLE OF TY_MARA, "To hold records from MARA Table
T_MVKE TYPE STANDARD TABLE OF TY_MVKE, "To hold records from MVKE Table
T_VBKD TYPE STANDARD TABLE OF TY_VBKD, "To hold records from VBKD Table
T_IHEADER TYPE STANDARD TABLE OF TY_IHEADER, "To hold records from VBAK Table
T_IFINAL TYPE STANDARD TABLE OF TY_IFINAL, "To hold cumulative data for ALV
T_BDCDATA TYPE STANDARD TABLE OF BDCDATA, "IT for bdcdata
T_BDCMSGCOLL TYPE STANDARD TABLE OF BDCMSGCOLL, "IT for error messages
T_MESSAGE1 TYPE STANDARD TABLE OF TY_MESSAGE1, "IT for conditions1 messages
T_MESSAGE2 TYPE STANDARD TABLE OF TY_MESSAGE2, "IT for conditions2 messages
T_ACC2 TYPE STANDARD TABLE OF TY_ACC2, "IT for holding data for Second Access Sequence Processing
T_ACC1 TYPE STANDARD TABLE OF TY_ACC1, "IT for holding data for First Access Sequence Processing
T_SELECT TYPE STANDARD TABLE OF RSPARAMS, "IT for holding data related to the selection screen
Work area Declarations
W_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV, "Fieldcatalog WA
W_EVENT TYPE SLIS_ALV_EVENT, "Event WA
W_HEADER TYPE SLIS_LISTHEADER, "Header WA
W_LAYOUT TYPE SLIS_LAYOUT_ALV, "Layout WA
W_KEYINFO TYPE SLIS_KEYINFO_ALV, "Key Information WA
W_VB_AKAP TYPE TY_VB_AKAP, "To hold records from T_VB_AKAP
W_MARA TYPE TY_MARA, "To hold records from T_MARA
W_MVKE TYPE TY_MVKE, "To hold records from T_MVKE
W_VBKD TYPE TY_VBKD, "To hold records from T_VBKD
W_IHEADER TYPE TY_IHEADER, "To hold records from T_IHEADER
W_IFINAL TYPE TY_IFINAL, "To hold records from T_IFINAL
W_PARAMS TYPE CTU_PARAMS, "CTU Params
W_BDCDATA TYPE BDCDATA, "Work Area for BDCDATA
W_BDCMSGCOLL TYPE BDCMSGCOLL, "Work Area to collect BDC Messages
W_MESSAGE1 TYPE TY_MESSAGE1, "WA for price conditions1 messages
W_MESSAGE2 TYPE TY_MESSAGE2, "WA for price conditions2 messages
W_ACC2 TYPE TY_ACC2, "WA for holding records from T_ACC2
W_ACC1 TYPE TY_ACC1, "WA for holding records from T_ACC1
Variable declarations
G_AUDAT TYPE AUDAT, "Document Date (Date Received/Sent)
G_VBELN TYPE VBELN_VA, "Sales Document
G_KUNNR TYPE KUNAG, "Sold-to party
G_MATNR TYPE MATNR, "Material Number
G_REPID TYPE SY-REPID, "Program Name
G_MESSAGE(73) TYPE C, "To Capture Message
G_FLAG1(1) TYPE C, "Flag
G_ANSWER(1) TYPE C. "Optional Button
Constant declarations
CONSTANTS:
C_A(1) TYPE C VALUE 'A', "Constant Value A
C_S(1) TYPE C VALUE 'S', "Constant Value S
C_U(1) TYPE C VALUE 'U', "Constant Value U
C_X(1) TYPE C VALUE 'X', "Constant Value X
C_E(1) TYPE C VALUE 'E', "Constant Value E
C_I(1) TYPE C VALUE 'I', "Constant Value I
C_R(1) TYPE C VALUE 'R', "Constant Value R
C_B(1) TYPE C VALUE 'B', "Document Category is Quotation
C_HTNAME(10) TYPE C VALUE 'T_IHEADER', "Internal table for Header Data
C_ITNAME(10) TYPE C VALUE 'T_IFINAL', "Internal Table with processed data
C_Q2(2) TYPE C VALUE 'Q2', "Constant Order Reason Q2
C_100(3) TYPE C VALUE '100', "Popup screen
C_046(3) TYPE C VALUE '046', "Value 046
C_047(3) TYPE C VALUE '047', "Value 047
C_25(2) TYPE C VALUE '25', "Popup screen
C_5(1) TYPE C VALUE '5', "Popup screen
C_1 TYPE I VALUE 1, "Value 1 for Error Denotion
C_2 TYPE I VALUE 2, "Value 2 for Error Denotion
C_3 TYPE I VALUE 3, "Value 3 for BDC Error Denotion
C_1000(4) TYPE N VALUE 1000, "Value 1000
C_01(2) TYPE N VALUE '01', "Value 01 for Zcount
C_VK11(4) TYPE C VALUE 'VK11', "Transaction VK11
C_DYNBEGIN(1) TYPE C VALUE 'X', "Indicator
C_UPDATE(1) TYPE C VALUE 'S', "Update
C_DISMODE(1) TYPE C VALUE 'N', "Display
C_ZBPR(4) TYPE C VALUE 'ZBPR', "Condition Type ZBPR
C_ERROR(5) TYPE C VALUE 'ERROR'. "Error screen title
S E L E C T O P T I O N S & P A R A M E T E R S *
Selection-screen Block 1
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_VKORG TYPE VKORG OBLIGATORY, "Sales Organization
P_VTWEG TYPE VTWEG OBLIGATORY, "Distribution Channel
P_SPART TYPE SPART DEFAULT '00'. "Division
SELECTION-SCREEN END OF BLOCK BLK1.
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS: S_AUDAT FOR G_AUDAT, "Document Date (Date Received/Sent)
S_VBELN FOR G_VBELN, "Sales Document
S_KUNNR FOR G_KUNNR, "Sold-to party
S_MATNR FOR G_MATNR. "Material Number
PARAMETERS: P_VKAUS(2) TYPE N. "Usage Indicator
SELECTION-SCREEN END OF BLOCK BLK2.
I N I T I A L I Z A T I O N *
INITIALIZATION.
CLEAR : G_REPID. "Program Name
G_REPID = SY-REPID. "Program Name
A T S E L E C T I O N S C R E E N *
AT SELECTION-SCREEN.
S T A R T O F S E L E C T I O N *
START-OF-SELECTION.
Data Selection
PERFORM DATA_RETRIEVAL.
Build Field Catalog
PERFORM BUILD_FIELDCATALOG.
Bulid layout
PERFORM BUILD_LAYOUT.
Build Events
PERFORM BUILD_EVENTS.
Captures the Values of Selection Screen
PERFORM CAPTURE_SCREEN.
E N D O F S E L E C T I O N *
END-OF-SELECTION.
Display List
PERFORM DISPLAY_ALV_REPORT.
F O R M S *
*& Form DATA_RETRIEVAL
Retrieves Data for ALV Display
FORM DATA_RETRIEVAL .
DATA : L_VKAUS TYPE VKAUS. "Variable to hold Usage Indicator
CLEAR L_VKAUS.
SELECT VBELN
KUNNR
INTO CORRESPONDING FIELDS OF TABLE T_IHEADER
FROM VBAK
WHERE VBELN IN S_VBELN
AND KUNNR IN S_KUNNR
AND VKORG EQ P_VKORG
AND AUDAT IN S_AUDAT
AND VTWEG EQ P_VTWEG
AND SPART EQ P_SPART
AND AUGRU EQ C_Q2
AND VBTYP EQ C_B.
IF NOT T_IHEADER IS INITIAL.
IF NOT P_VKAUS IS INITIAL OR P_VKAUS NE C_1.
CONCATENATE 'C' P_VKAUS INTO L_VKAUS.
SELECT A~VBELN
A~KUNNR
B~POSNR
B~MATNR
B~PMATN
B~KWMENG
B~VRKME
B~NETPR
B~KZWI1
B~VKAUS
INTO TABLE T_VB_AKAP
FROM VBAK AS A
JOIN VBAP AS B
ON A~VBELN EQ B~VBELN
FOR ALL ENTRIES IN T_IHEADER
WHERE A~VBELN EQ T_IHEADER-VBELN
AND B~MATNR IN S_MATNR
AND B~VKAUS EQ L_VKAUS.
ELSE.
SELECT A~VBELN
A~KUNNR
B~POSNR
B~MATNR
B~PMATN
B~KWMENG
B~VRKME
B~NETPR
B~KZWI1
B~VKAUS
INTO TABLE T_VB_AKAP
FROM VBAK AS A
JOIN VBAP AS B
ON A~VBELN EQ B~VBELN
FOR ALL ENTRIES IN T_IHEADER
WHERE A~VBELN EQ T_IHEADER-VBELN
AND B~MATNR IN S_MATNR.
ENDIF.
IF NOT T_VB_AKAP IS INITIAL.
SELECT VBELN
POSNR
BSTKD_E
INTO TABLE T_VBKD
FROM VBKD
FOR ALL ENTRIES IN T_VB_AKAP
WHERE VBELN EQ T_VB_AKAP-VBELN
AND POSNR EQ T_VB_AKAP-POSNR.
ENDIF.
SORT T_VBKD BY VBELN POSNR.
CLEAR W_VB_AKAP.
After much of coding was completed, Usage of PMATN was dropped and
the first eighteen characters of the field BSTKD was proposed for usage
Hence PMATN is overwritten by BSTKD value in the below loop
LOOP AT T_VB_AKAP INTO W_VB_AKAP.
CLEAR: W_VBKD,
W_VB_AKAP-PMATN.
READ TABLE T_VBKD INTO W_VBKD
WITH KEY VBELN = W_VB_AKAP-VBELN
POSNR = W_VB_AKAP-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
W_VB_AKAP-PMATN = W_VBKD-BSTKD_E+0(18).
ENDIF.
MODIFY T_VB_AKAP FROM W_VB_AKAP TRANSPORTING PMATN.
CLEAR W_VB_AKAP.
ENDLOOP.
IF NOT T_VB_AKAP IS INITIAL.
SELECT MATNR
ZZTECHSPEC
INTO TABLE T_MARA
FROM MARA
FOR ALL ENTRIES IN T_VB_AKAP
WHERE MATNR EQ T_VB_AKAP-MATNR.
IF SY-SUBRC EQ 0.
SORT T_MARA BY MATNR.
ENDIF. "Checking SY-SUBRC for T_MARA
SELECT MATNR
ZZTECHSPEC
APPENDING TABLE T_MARA
FROM MARA
FOR ALL ENTRIES IN T_VB_AKAP
WHERE MATNR EQ T_VB_AKAP-PMATN.
IF SY-SUBRC EQ 0.
SORT T_MARA BY MATNR.
ENDIF. "Checking SY-SUBRC for T_MARA
SELECT MATNR
VKORG
VTWEG
KONDM
INTO TABLE T_MVKE
FROM MVKE
FOR ALL ENTRIES IN T_VB_AKAP
WHERE MATNR EQ T_VB_AKAP-PMATN.
IF SY-SUBRC EQ 0.
SORT T_MVKE BY MATNR VKORG VTWEG.
ENDIF. "Checking SY-SUBRC for T_MVKE
SELECT MATNR
VKORG
VTWEG
KONDM
APPENDING TABLE T_MVKE
FROM MVKE
FOR ALL ENTRIES IN T_VB_AKAP
WHERE MATNR EQ T_VB_AKAP-MATNR.
IF SY-SUBRC EQ 0.
SORT T_MVKE BY MATNR VKORG VTWEG.
ENDIF. "Checking SY-SUBRC for T_MVKE
ENDIF. " FOR T_VB_AKAP NOT INITIAL.
ENDIF. " FOR T_IHEADER NOT INITIAL.
CLEAR: W_VB_AKAP,
W_IFINAL.
LOOP AT T_VB_AKAP INTO W_VB_AKAP.
W_IFINAL-VBELN = W_VB_AKAP-VBELN.
W_IFINAL-KUNNR = W_VB_AKAP-KUNNR.
W_IFINAL-POSNR = W_VB_AKAP-POSNR.
W_IFINAL-MATNR = W_VB_AKAP-MATNR.
W_IFINAL-PMATN = W_VB_AKAP-PMATN.
W_IFINAL-KWMENG = W_VB_AKAP-KWMENG.
W_IFINAL-VRKME = W_VB_AKAP-VRKME.
W_IFINAL-NETPR = W_VB_AKAP-NETPR.
W_IFINAL-KZWI1 = ( W_VB_AKAP-KZWI1 / W_VB_AKAP-KWMENG ) * 1000.
W_IFINAL-VKAUS = W_VB_AKAP-VKAUS.
Populating Material Pricing Group from New Material Group, if such Group doesn't exist
Population of Material Pricing Group from Material Number is tried.
Similar condition does suit for Tech Spec too.
SORT: T_MVKE BY MATNR VKORG VTWEG,
T_MARA BY MATNR.
IF NOT W_VB_AKAP-PMATN IS INITIAL.
CLEAR W_MVKE.
READ TABLE T_MVKE
INTO W_MVKE
WITH KEY MATNR = W_VB_AKAP-PMATN
VKORG = P_VKORG
VTWEG = P_VTWEG
BINARY SEARCH.
IF SY-SUBRC EQ 0.
W_IFINAL-KONDM = W_MVKE-KONDM.
ENDIF.
READ TABLE T_MARA
INTO W_MARA
WITH KEY MATNR = W_VB_AKAP-PMATN
BINARY SEARCH.
IF SY-SUBRC EQ 0.
W_IFINAL-ZZTECHSPEC = W_MARA-ZZTECHSPEC.
ENDIF. " SY-SUBRC FOR READ TABLE T_MARA
IF W_MVKE-KONDM IS INITIAL.
ELSE.
SORT T_MVKE BY MATNR VKORG VTWEG.
CLEAR W_MVKE.
READ TABLE T_MVKE
INTO W_MVKE
WITH KEY MATNR = W_VB_AKAP-MATNR
VKORG = P_VKORG
VTWEG = P_VTWEG
BINARY SEARCH.
IF SY-SUBRC EQ 0.
W_IFINAL-KONDM = W_MVKE-KONDM.
ENDIF.
READ TABLE T_MARA
INTO W_MARA
WITH KEY MATNR = W_VB_AKAP-MATNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
W_IFINAL-ZZTECHSPEC = W_MARA-ZZTECHSPEC.
ENDIF. " SY-SUBRC FOR READ TABLE T_MARA
ELSE.
W_IFINAL-KONDM = W_MVKE-KONDM.
ENDIF. " IS INITIAL CHECK FOR W_MVKE-KONDM
APPEND W_IFINAL TO T_IFINAL.
CLEAR: W_VB_AKAP,
W_IFINAL.
ENDLOOP.
SORT T_IFINAL BY VBELN.
Checking whether if there are any header quotations which does not have items against them in item internal table
if such records exist then, ensuring that such records gets deleted from header too, so that inconsitency is removed.
CLEAR W_IHEADER.
LOOP AT T_IHEADER INTO W_IHEADER.
CLEAR W_IFINAL.
READ TABLE T_IFINAL INTO W_IFINAL WITH KEY VBELN = W_IHEADER-VBELN.
IF SY-SUBRC NE 0.
W_IHEADER-SELECT = C_X.
MODIFY T_IHEADER FROM W_IHEADER TRANSPORTING SELECT.
ENDIF.
ENDLOOP.
DELETE T_IHEADER WHERE SELECT = C_X.
SORT T_IFINAL BY VBELN.
ENDFORM. " DATA_RETRIEVAL
*& Form build_layout
To build ALV Layout
FORM BUILD_LAYOUT.
CLEAR : W_LAYOUT.
W_LAYOUT-COLWIDTH_OPTIMIZE = C_X.
W_LAYOUT-BOX_TABNAME = C_HTNAME. "tabname for checkbox
W_LAYOUT-BOX_FIELDNAME = 'SELECT'. "fieldname for checkbox
CLEAR : W_KEYINFO.
W_KEYINFO-HEADER01 = 'VBELN'. "Header1 key information
W_KEYINFO-ITEM01 = 'VBELN'. "Item1 key information
ENDFORM. "build_layout
*& Form build_events
To build ALV Events
FORM BUILD_EVENTS.
CONSTANTS: C_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 1
IMPORTING
ET_EVENTS = T_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC = 0.
READ TABLE T_EVENTS INTO W_EVENT
WITH KEY NAME = C_TOP_OF_PAGE.
IF SY-SUBRC = 0.
MOVE C_TOP_OF_PAGE TO W_EVENT-FORM.
MODIFY T_EVENTS INDEX SY-TABIX
FROM W_EVENT
TRANSPORTING FORM.
ENDIF.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "build_events
*& Form top_of_page
To display top of page in ALV Report
FORM TOP_OF_PAGE. "#EC CALLED
DATA :
L_VKORG(35) TYPE C, "Sales Organization
L_VTWEG(35) TYPE C, "Distribution Channel
L_SPART(35) TYPE C. "Division
Title
CLEAR W_HEADER.
W_HEADER-TYP = C_H.
W_HEADER-INFO = TEXT-003.
APPEND W_HEADER TO T_HEADER.
Sales Organization
CLEAR W_HEADER.
W_HEADER-TYP = C_S.
CONCATENATE TEXT-004 P_VKORG INTO L_VKORG.
W_HEADER-INFO = L_VKORG.
APPEND W_HEADER TO T_HEADER.
Distribution Channel
CLEAR W_HEADER.
W_HEADER-TYP = C_S.
CONCATENATE TEXT-005 P_VTWEG INTO L_VTWEG.
W_HEADER-INFO = L_VTWEG.
APPEND W_HEADER TO T_HEADER.
Division
CLEAR W_HEADER.
W_HEADER-TYP = C_S.
CONCATENATE TEXT-006 P_SPART INTO L_SPART.
W_HEADER-INFO = L_SPART.
APPEND W_HEADER TO T_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM. "top_of_page
*& Form pf_status
To set PF-Status (user interface)
-->EXTAB The excluding table (function codes)
FORM PF_STATUS "#EC CALLED
USING T_EXTAB TYPE SLIS_T_EXTAB. "#EC NEEDED
SET PF-STATUS 'ZSTANDARD_FULLSCREEN'.
ENDFORM. "pf_status
*& Form display_alv_report
To display ALV report
FORM DISPLAY_ALV_REPORT.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = W_LAYOUT
IT_FIELDCAT = T_FIELDCATALOG
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_DEFAULT = C_X
I_SAVE = C_A
IS_VARIANT =
IT_EVENTS = T_EVENTS[]
IT_EVENT_EXIT =
I_TABNAME_HEADER = 'T_IHEADER'
I_TABNAME_ITEM = 'T_IFINAL'
I_STRUCTURE_NAME_HEADER =
I_STRUCTURE_NAME_ITEM =
IS_KEYINFO = W_KEYINFO
IS_PRINT =
IS_REPREP_ID =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
IR_SALV_HIERSEQ_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB_HEADER = T_IHEADER
T_OUTTAB_ITEM = T_IFINAL
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. "display_alv_report
*& Form BUILD_FIELDCATALOG
To build ALV Field Catalog
FORM BUILD_FIELDCATALOG .
DATA: L_COUNT TYPE I VALUE 0.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_HTNAME.
W_FIELDCATALOG-FIELDNAME = 'SELECT'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C01.
W_FIELDCATALOG-CHECKBOX = C_X.
W_FIELDCATALOG-EDIT = C_X.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_HTNAME.
W_FIELDCATALOG-FIELDNAME = 'VBELN'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C02.
W_FIELDCATALOG-KEY = C_X. "Fixes the column for no-scroll
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_HTNAME.
W_FIELDCATALOG-FIELDNAME = 'KUNNR'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C04.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR L_COUNT.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_ITNAME.
W_FIELDCATALOG-FIELDNAME = 'POSNR'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C03.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_ITNAME.
W_FIELDCATALOG-FIELDNAME = 'KWMENG'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C06.
W_FIELDCATALOG-EMPHASIZE = 'C400'.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_ITNAME.
W_FIELDCATALOG-FIELDNAME = 'VRKME'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C07.
W_FIELDCATALOG-JUST = C_R.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_ITNAME.
W_FIELDCATALOG-FIELDNAME = 'NETPR'.
W_FIELDCATALOG-FIELDNAME = 'KZWI1'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C08.
W_FIELDCATALOG-EMPHASIZE = 'C400'.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_ITNAME.
W_FIELDCATALOG-FIELDNAME = 'VKAUS'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C12.
W_FIELDCATALOG-JUST = C_R.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_ITNAME.
W_FIELDCATALOG-FIELDNAME = 'ZZTECHSPEC'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C09.
W_FIELDCATALOG-EMPHASIZE = 'C400'.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_ITNAME.
W_FIELDCATALOG-FIELDNAME = 'MATNR'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C05.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_ITNAME.
W_FIELDCATALOG-FIELDNAME = 'PMATN'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C10.
W_FIELDCATALOG-EMPHASIZE = 'C400'.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR W_FIELDCATALOG.
L_COUNT = L_COUNT + 1.
W_FIELDCATALOG-COL_POS = L_COUNT.
W_FIELDCATALOG-TABNAME = C_ITNAME.
W_FIELDCATALOG-FIELDNAME = 'KONDM'.
W_FIELDCATALOG-SELTEXT_M = TEXT-C11.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
ENDFORM. " BUILD_FIELDCATALOG
*& Form user_command
EXIT routine for command handling
-->L_UCOMM Function code that PAI triggered
-->W_SELFIELD Information cursor position ALV
FORM USER_COMMAND USING L_UCOMM LIKE SY-UCOMM "#EC CALLED
W_SELFIELD TYPE SLIS_SELFIELD. "#EC NEEDED
Check function code
CASE L_UCOMM.
WHEN 'CREATE'.
SORT T_IHEADER BY SELECT.
READ TABLE T_IHEADER INTO W_IHEADER
WITH KEY SELECT = C_X
BINARY SEARCH.
IF SY-SUBRC <> 0.
MESSAGE I000(ZS) WITH TEXT-M01.
ELSE.
CLEAR : G_ANSWER.
Dialog box for save prompts
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TEXT_QUESTION = TEXT-OP1
DISPLAY_CANCEL_BUTTON = ''
IMPORTING
ANSWER = G_ANSWER
EXCEPTIONS
TEXT_NOT_FOUND = 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.
ELSE.
IF G_ANSWER = 1.
SET PF-STATUS 'ZSTANDARD_SCREEN'.
PERFORM DATA_IDENTITY_4_ACCESS_SEQ.
PERFORM CREATE_CONDITIONS.
PERFORM DISPLAY_RESULT.
ENDIF.
ENDIF.
ENDIF.
WHEN '&REFRESH'.
SUBMIT ZSPRENH069 USING SELECTION-SCREEN 1000
WITH SELECTION-TABLE T_SELECT.
WHEN 'BACKTO'.
SUBMIT ZSPRENH069 USING SELECTION-SCREEN 1000
WITH SELECTION-TABLE T_SELECT.
ENDCASE.
ENDFORM. "user_command
*& Form DATA_IDENTITY_4_ACCESS_SEQ
Seperates the Available Data for processing for both Access Sequences
FORM DATA_IDENTITY_4_ACCESS_SEQ .
CLEAR : W_IFINAL,
W_ACC1,
W_ACC2.
SORT T_MVKE BY MATNR VKORG VTWEG.
LOOP AT T_IHEADER INTO W_IHEADER WHERE SELECT = C_X.
LOOP AT T_IFINAL INTO W -
How to make a entire column editable in an ALV grid
Hi all,
I am trying to make a column editable in an ALV grid. For that I wrote the following code. In the below code I have set the 'edit' field of ls_fcat to 'X'. But Iam getting Runtime error. Can anyone help in resolving this problem or suggest any method to make a column editable in an ALV grid.
form prepare_fc changing go_fieldcat type lvc_t_fcat.
data: ls_fcat type lvc_s_fcat.
refresh: go_fieldcat.
clear: ls_fcat.
ls_fcat-reptext = ' Safety Stock Figures'.
ls_fcat-coltext = 'Safety Stock Figures'.
ls_fcat-fieldname = 'EISBE'.
ls_fcat-ref_table = 'IMAT'.
ls_fcat-edit = 'X'.
modify go_fieldcat from ls_fcat.
APPEND LS_FCAT TO GO_FIELDCAT.
endform.
Thanks & Regards,
Vishnu Priya.ls_fcat-edit = 'X'.
is correct only.
have a look into this code
struct_grid_lset TYPE lvc_s_layo,
i_grid_fcat TYPE lvc_t_fcat
DATA ls_fcat TYPE lvc_s_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'MONTH'.
ls_fcat-ref_table = 'TYPE'.
ls_fcat-ref_field = 'C'.
<b> ls_fcat-edit = 'X'.</b>
ls_fcat-coltext = text-030."Month
ls_fcat-seltext = text-030.
APPEND ls_fcat TO p_i_grid_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'YEAR'.
ls_fcat-ref_table = 'TYPE'.
ls_fcat-ref_field = 'C'.
ls_fcat-coltext = text-031."Year
ls_fcat-seltext = text-031.
APPEND ls_fcat TO p_i_grid_fcat.
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
i_bypassing_buffer = space
is_variant = ws_f_grid_disvar
i_save = ws_c_grid_save
is_layout = struct_grid_lset
CHANGING
it_outtab = i_grid_outs[]
<b>it_fieldcatalog = i_grid_fcat[]</b>
it_sort = i_sort_fcat. " Period
Also Check this code.Another way using field symbols.
i_fieldcat TYPE lvc_t_fcat,
w_layout TYPE lvc_s_layo ,
w_variant TYPE disvariant.
FIELD-SYMBOLS : <lfs_fieldcat> TYPE lvc_s_fcat.
*Default display
LOOP AT p_fieldcat ASSIGNING <lfs_fieldcat>.
CASE <lfs_fieldcat>-fieldname.
WHEN 'GL_ACCT'.
<lfs_fieldcat>-coltext = text-050.
<lfs_fieldcat>-no_out = ' '.
<lfs_fieldcat>-scrtext_l = text-050.
<b> <lfs_fieldcat>-edit = 'X'.</b>
WHEN OTHERS.
ENDCASE.
ENDLOOP.
Hope this helps. -
Hiding a column when displaying an alv
Hi Gurus,
Shortly I have these things :
1) A node with some attributes like customer_no, customer_name, status etc.
2) A view which contains an element(viewcontainerelement) and this displays the node.
This node is in CONTEXT of my view and in componentcontroller.
Now i want to hide some attributes(columns) when displaying this alv. Can anybody help me?
Thanks..Hi,
When i write that code, it gives me an error message :
data: lr_salv_column type ref to cl_salv_wd_column,
lr_salv_table type ref to cl_salv_wd_config_table.
lr_salv_column = lr_salv_table-if_salv_wd_column_settings~get_column( 'm_no' ).
lr_salv_column->set_visible( if_wdl_core=>visibility_blank ).
Error message:
"Class "CL_MAINV_CTR" does not contain an interface
"LR_SALV_TABLE-IF_SALV_WD_COLUMN_SETTINGS". "
"Mainv" is the name of my view.
I am new at WDA, please give me detailed information.
Thanks
Edited by: Adil Gündüz on Sep 22, 2008 11:13 AM -
How to make a particular row and column field editable in ALV
Hi Experts,
I have a requirement to make a particular row and column field editable in ALV output. Like i need to make 2nd row - 4th column editable of ALV output.
Kindly help me out to solve this.
Any help would be appreciated.
Thanks,
AshutoshHi Ashutosh,
please check below, explained by some experts.
In the below link editing two columns MOD_RANK and TECH_RANK.
These two columns will be in edit mode once after selecting the required record
Editing single cell in a row of ALV table
And also look for more info
http://scn.sap.com/thread/884976 -
As I can capture or recognize a column selected in a ALV ?
I'm not sure if you can recognize more selected colums, but you can definitely read the column name which is selected as the first in the field catalog.
If it runs to user_command form, you'll find it in the rs_selfield-fieldname. The rs_selfield structure itself will provide you with more information what might be useful, check it yourself.
Filip -
Hi Friends,
I need to put a pushbutton in ALV List's every row. And then when user click this button, I will get the selected line of list. My application server is 4.6 and I want to implement this using the function call of CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY', not using object oriented programming. How can I put button in alv list and get the selected line when button is clicked?
Thanks.U can not do it by 'Reuse_alv*'. You have to use class for that. Here is the example: I have created a pushbutton 'Download file'.
report z_82235_alv_oops_pustbutton .
tables: mara.
types: begin of t_mara,
matnr type matnr,
mtart type mtart,
matkl type matkl,
meins type meins,
end of t_mara.
data: gt_mara type standard table of t_mara,
gs_mara like line of gt_mara.
class lcl_event_receiver definition deferred.
*-- Global Data defenation for ALV
*---Alv Grid instance referance
data : gr_alvgrid type ref to cl_gui_alv_grid,
event_receiver type ref to lcl_event_receiver.
*---Name of the custom control added on the screen
data gc_custom_control_name type scrfname value 'CC_ALV'
*---Custom container instance referance
data: gr_ccontainer type ref to cl_gui_custom_container.
*---Field catalog table
data: gt_fieldcat type lvc_t_fcat,
gs_fieldcat type lvc_s_fcat.
*---Layout structure
data: gs_layout type lvc_s_layo.
data: g_repid like sy-repid.
select matnr
mtart
matkl
meins
from mara into table gt_mara
up to 25 rows.
g_repid = sy-repid.
include <icon>.
* Predefine a local class for event handling to allow the
* declaration of a reference variable before the class is defined.
* Set initial dynpro
set screen 100.
* LOCAL CLASSES: Definition
*===============================================================
* class lcl_event_receiver: local class to
* define and handle own functions.
* Definition:
* ~~~~~~~~~~~
class lcl_event_receiver definition.
public section.
methods:
handle_toolbar
for event toolbar of cl_gui_alv_grid
importing e_object e_interactive,
handle_user_command
for event user_command of cl_gui_alv_grid
importing e_ucomm.
private section.
endclass.
* lcl_event_receiver (Definition)
*===============================================================
* LOCAL CLASSES: Implementation
*===============================================================
* class lcl_event_receiver (Implementation)
class lcl_event_receiver implementation.
method handle_toolbar.
* § 2.In event handler method for event TOOLBAR: Append own functions
* by using event parameter E_OBJECT.
data: ls_toolbar type stb_button.
* E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.
* This class has got one attribute, namly MT_TOOLBAR, which
* is a table of type TTB_BUTTON. One line of this table is
* defined by the Structure STB_BUTTON (see data deklaration above).
* A remark to the flag E_INTERACTIVE:
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 'e_interactive' is set, if this event is raised due to
* the call of 'set_toolbar_interactive' by the user.
* You can distinguish this way if the event was raised
* by yourself or by ALV
* (e.g. in method 'refresh_table_display').
* An application of this feature is still unknown... :-)
* append a separator to normal toolbar
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
* append an icon to download
clear ls_toolbar.
ls_toolbar-function = 'DOWN'.
ls_toolbar-icon = 'icon_generate'.
ls_toolbar-quickinfo = 'DOWNLOAD FILE'.
ls_toolbar-text = 'DOWNLOAD FILE'.
* MOVE ' ' TO ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
endmethod.
method handle_user_command.
* § 3.In event handler method for event USER_COMMAND: Query your
* function codes defined in step 2 and react accordingly.
data: lt_rows type lvc_t_row.
case e_ucomm.
when 'DOWN'.
call function 'GUI_DOWNLOAD'
exporting
* BIN_FILESIZE =
filename = 'D:a.txt'
* FILETYPE = 'ASC'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
tables
data_tab = gt_mara
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endcase.
endmethod. "handle_user_command
endclass.
* lcl_event_receiver (Implementation)
*===================================================================
* S T A R T - O F - S E L E C T I O N.
start-of-selection.
set screen '100'.
*& Module display_alv OUTPUT
* text
module display_alv output.
if gr_alvgrid is initial.
*---Creating custom container instance
create object gr_ccontainer
exporting
container_name = gc_custom_control_name
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
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.
*---Creating ALV gris instance
create object gr_alvgrid
exporting
i_parent = gr_ccontainer
i_appl_events = 'X'
exceptions
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
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.
*---Prepare field catalog
perform prepare_field_catalog tables gt_fieldcat.
*---Prepare layout
perform prepare_layout changing gs_layout.
*---Call ALV grid
call method gr_alvgrid->set_table_for_first_display
exporting
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = gs_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
changing
it_outtab = gt_mara[]
it_fieldcatalog = gt_fieldcat
* IT_SORT =
* IT_FILTER =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
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.
* ->Create Object to receive events and link them to handler methods.
* When the ALV Control raises the event for the specified instance
* the corresponding method is automatically called.
create object event_receiver.
set handler event_receiver->handle_user_command for gr_alvgrid.
set handler event_receiver->handle_toolbar for gr_alvgrid.
* § 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.
call method gr_alvgrid->set_toolbar_interactive.
* endif. "IF grid1 IS INITIAL
* call method cl_gui_control=>set_focus exporting control = gr_alvgrid.
*--- the instance is present
else .
call method gr_alvgrid->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
exceptions
finished = 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.
endif.
endmodule. " display_alv OUTPUT
*& Form prepare_field_catalog
* text
* <--P_GT_FIELDCAT text
form prepare_field_catalog tables gt_fieldcat.
clear : gs_fieldcat.
gs_fieldcat-fieldname = 'MATNR'.
gs_fieldcat-col_pos = 1.
gs_fieldcat-emphasize = 'X'.
gs_fieldcat-outputlen = 10.
gs_fieldcat-coltext = 'Material No'.
gs_fieldcat-edit = 'X'.
append gs_fieldcat to gt_fieldcat.
clear : gs_fieldcat.
gs_fieldcat-fieldname = 'MTART'.
gs_fieldcat-col_pos = 2.
gs_fieldcat-outputlen = 6.
gs_fieldcat-coltext = 'Material Type'.
append gs_fieldcat to gt_fieldcat.
clear : gs_fieldcat.
gs_fieldcat-fieldname = 'MATKL'.
gs_fieldcat-col_pos = 3.
gs_fieldcat-outputlen = 5.
gs_fieldcat-coltext = 'Material Grp'.
append gs_fieldcat to gt_fieldcat.
clear : gs_fieldcat.
gs_fieldcat-fieldname = 'MEINS'.
gs_fieldcat-col_pos = 4.
gs_fieldcat-outputlen = 4.
gs_fieldcat-coltext = 'Unit'.
append gs_fieldcat to gt_fieldcat.
endform. " prepare_field_catalog
*& Form prepare_layout
* text
* <--P_GS_LAYOUT text
form prepare_layout changing p_gs_layout type lvc_s_layo.
p_gs_layout-zebra = 'X'.
p_gs_layout-grid_title = 'Material'.
p_gs_layout-smalltitle = 'X'.
endform. " prepare_layout
*& Module STATUS_0100 OUTPUT
* text
module status_0100 output.
set pf-status 'STATUS1'.
* SET TITLEBAR 'xxx'.
endmodule. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
module user_command_0100 input.
case sy-ucomm.
when 'BACK' or 'UP' or 'CANCEL'.
leave program.
when '&DETAIL'.
leave program.
endcase.
endmodule. " USER_COMMAND_0100 INPUT -
Need multiple lines in single column of header using alv oops
Hi
I am using alv oops in a report.
I need multiple lines in single column of header.
In header of my report i am using 9 columns.
In the second column i need to split the line
Notification description/activity/work/activity long text/
as
Notification description/
activity/
work/
activity long text/
Please guide me to achieve this functionality.It is not possible to break the column description in the ALV disply.
Actually, if you have a longer description in one of the seltext_* field of the fiels catalog, it will automatically display it as a tooltip, if you put the mouse over the heading. In ALV OO, you can explicitly set the tooltip text.
Also you can get more help on the field pressing F1: If you use DDIC fields, it it automatic, otherwise you can do it as you like. -
How to make fields/columns un-editable in ALV
Hi,
How can I make a field/column un-editable in ALV.
I tried writing: ls_fc_po-edit = ' '. (inside loop for the selected column/field), but it doesnot work for me.
Any suggestions please.
Thanks,
RavishThe code for the field catalogue is below:
LOOP AT lt_fc_po INTO ls_fc_po.
IF ls_fc_po-fieldname EQ 'PO_ID'.
ls_fc_po-no_out = 'X'.
ELSEIF ls_fc_po-fieldname EQ 'UNIT_OF_MEASURE'.
ls_fc_po-outputlen = '10'.
ls_fc_po-tooltip = 'Unit of Measure'.
ELSEIF ls_fc_po-fieldname EQ 'ITEM_ID'.
ls_fc_po-outputlen = '10'.
ls_fc_po-tooltip = 'Purchase Order Items'.
ELSEIF ls_fc_po-fieldname EQ 'QUANTITY'.
ls_fc_po-outputlen = '10'.
ELSEIF ls_fc_po-fieldname EQ 'CURRENCY'.
ls_fc_po-edit = ' '.
ls_fc_po-outputlen = '10'.
ls_fc_po-tooltip = 'Currency'.
ELSEIF ls_fc_po-fieldname EQ 'DATE_OF_DELIVERY'.
ls_fc_po-outputlen = '18'.
ls_fc_po-coltext = 'Delivery Date'.
ls_fc_po-tooltip = 'Requested Delivery date'.
ELSEIF ls_fc_po-fieldname EQ 'PLANT_ID'.
ls_fc_po-outputlen = '15'.
ls_fc_po-coltext = 'Plant'.
ls_fc_po-tooltip = 'Plant Identifier'.
ELSEIF ls_fc_po-fieldname EQ 'MATERIAL_DESC'.
ls_fc_po-outputlen = '18'.
ELSEIF ls_fc_po-fieldname EQ 'MATERIAL_ID'.
ls_fc_po-outputlen = '15'.
ls_fc_po-coltext = 'Material'.
ls_fc_po-tooltip = 'Material Identifier'.
IF GL_PO_EVENT_ALV = 0.
GL_PO_EVENT_ALV = 1.
data: l_field type lvc_fname.
data: lt_f4 type lvc_t_f4.
data: ls_f4 type lvc_s_f4.
l_field = ls_fc_po-fieldname.
ls_f4-fieldname = l_field.
ls_f4-register = 'X'.
ls_f4-getbefore = 'X'.
ls_f4-chngeafter = 'X'.
append ls_f4 to lt_f4.
CALL METHOD po_itm_trn_alvgrid->register_f4_for_fields
EXPORTING
it_f4 = lt_f4.
ENDIF.
ENDIF.
MODIFY lt_fc_po FROM ls_fc_po.
ENDLOOP. -
How to make 1st column as header in ALV grid
Hi Experts,
How to make 1st column as header in ALV grid as attached. Please help.
Thanks in advance.Hi manoj,
Try with,
FM REUSE_ALV_HIERSEQ_LIST_DISPLAY
Regards,
Venkat. -
Hello,
I have to create an ALV(not using OO) with a pushbutton column. The requirement is as follows: the grid contains a text column. When the text contains more than 100 characters, a column with a pushbutton (named: More...) is selected by the user to view the rest of the text description. Scrolling within the text column is not desired.
Can someone tell me how to define the column as a pushbutton. How about how to disable the pushbutton for the row, when the text is less than 100 characters? I am thinking that I can handled the event in the user_command area of the ALV.
Can this be done?
Regards,
Anna-LizaHi
You can show a field as ICON (it menages it in catalog table) and assign the HOTSPOT option to it.
In this way the field should behave itself like a push button.
As soon as you know the row you can decide which action has to be done: to show or not to show the rest of text:
you can do it activing the event HOTSPOT_CLICK.
Max -
hi Im working on an alv report,in the output list i have to get pushbutton for every row as a separate column.please help me out with some code,i had gone trough sap sample ALV programs but i did not find this type of programs.Thank you.
Regards
AnilHi Babita,
ok no need to worry, you can do that with the help of FM <b>REUSE_ALV_GRID_DISPLAY_LVC</b>, but New FM , i am not sure if you have this or not. if it is there you can very well do it. just check this code...
REPORT ZTESTALV.
TYPE-POOLS: SLIS.
*- Fieldcatalog
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV..
*- For Events
DATA:IT_EVENTS TYPE SLIS_T_EVENT.
DATA: X_FIELDCAT TYPE LVC_S_FCAT,
X_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV.
DATA:X_LAYOUT TYPE LVC_S_LAYO.
DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
BUTTON(10),
END OF IT_VBAP.
DATA: LS_OUTTAB LIKE LINE OF IT_VBAP.
SELECT VBELN
POSNR
UP TO 10 ROWS
INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
FROM VBAP.
DATA:L_POS TYPE I VALUE 1.
CLEAR: L_POS.
L_POS = L_POS + 1.
X_FIELDCAT-SELTEXT = 'Button'.
x_fieldcat-fieldname = 'BUTTON'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-style = X_FIELDCAT-style bit-xor
cl_gui_alv_grid=>MC_STYLE_BUTTON bit-xor
cl_gui_alv_grid=>MC_STYLE_ENABLEd.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SELTEXT = 'VBELN'.
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-OUTPUTLEN = '10'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SELTEXT = 'POSNR'.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT_LVC = X_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCAT
TABLES
T_OUTTAB = IT_VBAP[]
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.
Regards
vijay -
Md04 - additional columns as pushbutton
Implementing the badi MD_ADD_COL_EZPS
How can I add a column and the content of the column is a pushbutton ????
thanks in advance
StephanHi Stephen,
I just made this particular enhancement. You first have to check if the BADI - MD_ADD_COL_EZPS - is activated. If it is then you will have to do the enhancement using the BADI, else you can use the combination of the two following User-exits :
EXIT_SAPLM61R_001, EXIT_SAPMM61R_001.
Thanks & Regards,
Aditya -
Dynamic value assignment to a particular column in a vertical ALV
Hi Friends,
In the present program ALV has 44 fields and output row is only one(with some field editable).
My requirement is to change present output to vertical ALV and editable field should be available
as editable.
Now I have changed this to transposed ALV manually(not dynamically) with required fields editable.
Now there is 44 rows and two column "FIELD and "VALUE'.Some values in the second column is editable.
Previously output was like this:
field1 field2 field3 ...
val1 val2 val3 ...
Now output is like:
FIELD VALUE
field1 value1(type INT)
field2 value2(type char5) Editable(need F4 help)
field3 value3(type date)
My present structure declaration is:
types: begin of ty_itab,
field type char 50,
value type char70,
celltab type lvc_t_styl,(for editing some values in VALUE column).
end of ty_itab.
data: itab type standard table of ty_itab.
Now the second column i have declared as CHAR70 which contains only char
values because to put all differt types of values to one single column named
'VALUE'.
But as field1 field2 field3... had differnt type of value like integer char date...I need to validate some values
(specially those which are editable) before saving to custom DB table.
So I need dynamic value assignment to VALUE column when preparing internal table for display.
What I want to say is that VALUE column should be able to contain different type of values like INT, DATE, CHAR...etc
Is the requirement is feasible?
If yes then How should I declare the structure and populate different type of values within single column 'VALUE'.
Also is it possible to have F4 helps in the second column (VALUE)???Hi Manab,
I did something comparable: We have a very complex transaction with several subscreens with multiple fields to be filled with complex logic to create a very special contract. The requirement was to create a method to create a copy of this contract being able to apply some changes.
I created a wizard (transaction SBPT_WIZARD_BUILDER - Wizard-Builder) to accomplish that. I grouped all the fields to just 3 logical groups and thius created 3 stesp where the user gets an ALV as you describe, but we have the rows like FIELD with the new value editable. Additionally I have hidden fields with table name and field name so that I can determine the characteristics (datatype) at run time.
The value fields are just strings (every ALV field is a text field on the surface).
For editable fields, you have an event DATA_CHANGED. I used this method as a handler for the event:
(I will leave out the wizard part here - maybe a good idea for a blog to explain that)
METHOD handle_data_changed.
CALL FUNCTION 'RS_CONV_EX_2_IN'
EXPORTING
input_external = <mod>-value
table_field = ls_tabfield
I also created handlers for F1 and F4
Handler for CL_GUI_ALV_GRID->ONF1
METHOD handle_f1.
CALL FUNCTION 'HELP_OBJECT_SHOW_FOR_FIELD'
EXPORTING
called_for_tab = lv_tabname
called_for_field = lv_fieldname
EXCEPTIONS
object_not_found = 1
sapscript_error = 2
OTHERS = 3.
Handler for CL_GUI_ALV_GRID->HANDLE_F4
METHOD handle_f4.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
tabname = lv_tabname
fieldname = lv_fieldname
TABLES
return_tab = lt_return_tab
EXCEPTIONS
OTHERS = 5.
er_event_data->m_event_handled = abap_true.
* if er_event_data->m_event_handled is not set to abap_true, system will handle it.
* In this context the message 'Keine Eingabehilfe verfügbar' will be displayed
ENDMETHOD.
This is just an excerpt from my project. It shows that you can do more in ALV as you knew.
I tried to post a little more but the formatting break down, possibly a result of the character limit
Regards,
Clemens -
How to find number of columns used in a ALV variant
I need to know how many column is active ( will be shown in the ALV report ) related to a specific ALV Variant.
Example :
The structure of my internal table has 147 columns.
The user in a specific ALV variant has chosen 25 columns of those 147 colums, so I need to know that this ALV variant will show 25 columns.
Thanks! JoHi Max,
Thanks for hints.
Finnally I did the verification at the beginning of my process.
Because I need the information before getting the data, so I called the METHOD with a "dummy" table,
and I received the info of what I need, the number of column related to a specific ALV Variant.
I used :
ls_variant-report = sy-repid.
ls_variant-variant = p_alvvar. "<<< Select-option field for AVL Variant
ls_variant-log_group = 'L01'.
CALL METHOD lo_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'MY_STRUCTURE'
is_variant = ls_variant
is_layout = ls_layout
i_save = 'A'
i_default = 'X'
I_BYPASSING_BUFFER = 'X'
CHANGING
it_fieldcatalog = LT_FIELDCATALOG
it_outtab = lt_dummy[].
CALL METHOD lo_grid1->GET_FRONTEND_FIELDCATALOG
IMPORTING
ET_FIELDCATALOG = LT_FIELDCATALOG.
loop at LT_FIELDCATALOG into ls_FIELDCATALOG where no_out = space.
add 1 to LV_NB_COLUMNS.
endloop.
Jo
Maybe you are looking for
-
TOMCAT problem on REDHAT 9,PLEASE HELP
Hello, i am new to redhat and i installed tomcat 4.0.1 and it worked properly, i used tomcat for studying issues so i used to start it and stop it many times now when i use mozilla and try to request the server using http://localhost:8080/ ,mozilla s
-
External table.How to load numbers (decimal and scientific notation format)
Hi all, I need to load inside an external table records that contain 7 fields. The last field is called AMOUNT and it's represented in some records with the decimal format, in others records with the scientific notation format as, for example, below:
-
Unable to sync full 'Photos' album in iTunes
Since updating to OSX 10.10.3, I am no longer able to fully sync my albums in Photos to my iPhone 6 via iTunes (12.1.2.27) I have an album in Photos titled iPhone 3G/4. It contains all of the photos I shot on my previous iphones. The album totals 7,5
-
Getting error when we loading the data to 0TCT_C01
When we are loading the delta loads to 0TCT_C01 cube , Load got failed saying that "Job terminated in source system --> Request set to red". Below is the details abou the dump: Runtime Errors COMPUTE_INT_TIMES_OVERFLOW Exception
-
Passing extra compiler options to flexunit ANT task?
Hi, Is there a way to send any extra compiler options to the <flexunit> ANT task? I'm using conditional compilation and compilation (mxmlc) is failing from the <flexunit> task: "Error: Access of undefined property DEBUG. CONFIG::DEBUG {" I tried snea