‎2008 May 05 11:32 AM
hi ,
A very gud day to u all experts.........
In interactive ALV , is there any thing like HIDE statement..
Plz give me a examlple program for interactive alv
Thank you
with regards..
Always learner
‎2008 May 05 11:33 AM
‎2008 May 05 11:33 AM
‎2008 May 05 11:37 AM
‎2008 May 05 11:38 AM
In ALV there is no HIDE statement. U have to use User_command.
I_CALLBACK_USER_COMMAND
EXIT routine for command handling
Passing an EXIT routine tells ALV that the application wants to react to certain function codes itself. These are general function codes which ALV does not recognize (not ALV standard functions) and which were defined and set by an application status.
FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
The parameter R_UCOMM contains the function code called.
*&---------------------------------------------------------------------*
*& Report ZM_REPT_BLOCK_VENDORS *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
**********************************************************************
* Program name : ZM_REPT_BLOCK_VENDORS *
* *
* Title : display and block vendors *
* Requestor : *
* Author : *
* Date : *
* *
* Functional contact : *
* *
* Program description: A report to select those vendors for whome *
* purchase orders has not been passed since *
* six months and all already passed purchase *
* orders has been delivered, and then to block *
* those selected vendors by using BDC *
* call transaction method *
* *
* Input Selection Screen: no selections *
* *
* Report Parameters: no parameters *
* Report Output: Check box *
* vendor number - LFA1-LIFNR *
* vendor name - LFA1-NAME1 *
* company code - LFB1-WERKS *
* PO number - EKKO-EBELN *
* Item number - EKPO-EBELP *
* Delivery indicator - EKPO-ELIKZ *
* -------------------------------------------------------------------- *
* MODIFICATIONS : *
**---------------------------------------------------------------------*
* M A I N T E N A N C E L O G *
*--------------------------------------------------------------------- *
*--D A T E---|--B Y--|-C H A N G E N O.-| D E S C R I P T I O N ----- *
* | | | *
*--------------------------------------------------------------------- *
************************************************************************
REPORT zm_rept_block_vendors NO STANDARD PAGE HEADING LINE-SIZE 90
LINE-COUNT 30(3). .
*----------------------------------------------------------------------*
* Tables - Database tables *
*----------------------------------------------------------------------*
TABLES: ekko,lfa1,lfb1,ekpo.
*----------------------------------------------------------------------*
* data declaration part *
*----------------------------------------------------------------------*
*INTERNAL TABLES.
DATA:BEGIN OF it_lfb1 OCCURS 0,
lifnr LIKE lfa1-lifnr,
name1 LIKE lfa1-name1,
bukrs LIKE lfb1-bukrs,
END OF it_lfb1.
DATA: BEGIN OF it_ekpo OCCURS 0,
lifnr LIKE ekko-lifnr,
ebeln LIKE ekko-ebeln,
ebelp LIKE ekpo-ebelp,
elikz LIKE ekpo-elikz,
END OF it_ekpo.
DATA: it_vendors LIKE TABLE OF it_ekpo WITH HEADER LINE.
*table to select all the vendors for whome no POs passed since six
*months.
DATA: BEGIN OF it_vend OCCURS 0,
lifnr LIKE lfa1-lifnr,
name1 LIKE lfa1-name1,
bukrs LIKE lfb1-bukrs,
ebeln LIKE ekko-ebeln,
ebelp LIKE ekpo-ebelp,
elikz LIKE ekpo-elikz,
END OF it_vend.
*internal table to select all vendors for whome there is no open items
DATA: BEGIN OF it_block OCCURS 0,
cbox ,
lifnr LIKE lfa1-lifnr,
name1 LIKE lfa1-name1,
bukrs LIKE lfb1-bukrs,
ebeln LIKE ekko-ebeln,
ebelp LIKE ekpo-ebelp,
elikz LIKE ekpo-elikz,
END OF it_block.
*internal table to select vendors to be blocked for a perticular plant.
DATA: BEGIN OF it_select OCCURS 0,
lifnr_001(016),
bukrs_002(004),
loevm_003(001),
loevm_004(001),
nodel_005(001),
nodel_006(001),
END OF it_select.
* internal table to handle the messages
DATA bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
*DATA VERIABLES
DATA: w_aedat LIKE sy-datum, " for six months back date
ok_code LIKE sy-ucomm, " to hold function codes
currdate LIKE sy-datum, " To hold the current date
backmonths TYPE i.
DATA: c1 TYPE i, " counter for POs of each vendor
c2 TYPE i, " counter for delevery completed POs
l_no TYPE i, " to store line no at list output
tot_rec TYPE i. " to store no of records in the basic list
*----------------------------------------------------------------------*
* INITIALIZATION EVENT *
*----------------------------------------------------------------------*
INITIALIZATION.
currdate = sy-datum.
backmonths = 6.
PERFORM go_back_months USING currdate backmonths CHANGING w_aedat.
*----------------------------------------------------------------------*
* START-OF-SELECTION EVENT *
*----------------------------------------------------------------------*
START-OF-SELECTION.
*selection statement to select all vendors for whome POs has not been
* passed for six months, and all POs and items for that vendor includng
* company code
PERFORM initial_selection.
*----------------------------------------------------------------------*
* END-OF-SELECTION EVENT *
*----------------------------------------------------------------------*
END-OF-SELECTION.
SORT it_vend BY lifnr bukrs ebeln ebelp.
*to display all vendors for whom POs has not been passed for six months
* PERFORM disply_all_vendors.
*to select those vendors into it_block table for whom there is no open
*items
PERFORM select_no_openitems.
*to display initial selection data.
PERFORM display_initial_selection .
* to set PF status for basic list.
IF sy-lsind = 0.
SET PF-STATUS 'RAM'.
ENDIF.
*----------------------------------------------------------------------*
* TOP-OF-PAGE EVENT *
*----------------------------------------------------------------------*
TOP-OF-PAGE.
* headings for basic list
PERFORM top-of-page.
*----------------------------------------------------------------------*
* TOP-OF-PAGE DURING LINE-SELECTION EVENT *
*----------------------------------------------------------------------*
TOP-OF-PAGE DURING LINE-SELECTION.
* headings for secondary list
PERFORM top_of_page_for_second_list.
*----------------------------------------------------------------------*
* AT USER-COMMAND EVENT *
*----------------------------------------------------------------------*
AT USER-COMMAND.
IF sy-lsind = 1.
SET PF-STATUS 'RAM'.
ENDIF.
ok_code = sy-ucomm.
CASE ok_code.
* to select all vendors for all company codes from the basic list.
WHEN 'SALL'.
PERFORM select_all.
* to deselect all vendors for all company codes from the basic list.
WHEN 'DALL'.
PERFORM deselect_all.
* to store and display the selected vendors to be blocked
WHEN 'SLCT'.
PERFORM final_selection.
* display the selected vendors and details to be blocked
PERFORM display_final_selection.
WHEN 'RBDC'.
PERFORM final_selection.
* to perform BDC by call transaction using table it_select.
PERFORM run_bdc.
WHEN 'RFRS'.
* to refresh the output.
SUBMIT ZM_REPT_BLOCK_VENDORS AND RETURN .
ENDCASE.
CLEAR ok_code.
*&---------------------------------------------------------------------*
*& Form GO_BACK_MONTHS *
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> CURRDATE text *
* --> BACKMONTHS text *
* <-- NEWDATE *
*----------------------------------------------------------------------*
FORM go_back_months USING value(currdate) value(backmonths)
CHANGING newdate.
DATA: year(4) TYPE c,
tmonths TYPE numc3,
day(2) TYPE c,
leaf TYPE i.
MOVE: currdate(4) TO year,
currdate+4(2) TO tmonths,
currdate+6(2) TO day.
IF tmonths <= backmonths.
currdate(4) = currdate(4) - 1.
currdate+4(2) = '12'.
backmonths = backmonths - tmonths.
* call function recursively
PERFORM go_back_months USING currdate backmonths CHANGING newdate.
ELSE.
newdate(4) = currdate(4).
newdate+4(2) = currdate+4(2) - backmonths.
newdate+6(2) = currdate+6(2).
IF newdate+6(2) = '31'.
IF newdate+4(2) = '01' OR newdate+4(2) = '03' OR
newdate+4(2) = '05' OR newdate+4(2) = '07' OR
newdate+4(2) = '08' OR newdate+4(2) = '10' OR
newdate+4(2) = '12' .
newdate+6(2) = '31'.
ELSE.
leaf = newdate(4) MOD 4.
IF leaf = 0 AND newdate+4(2) = 2.
newdate+6(2) = '29'.
ELSEIF newdate+4(2) = 2.
newdate+6(2) = '28'.
ELSE.
newdate+6(2) = '30'.
ENDIF.
ENDIF.
ELSEIF newdate+6(2) = '30' .
leaf = newdate(4) MOD 4.
IF leaf = 0 AND newdate+4(2) = 2.
newdate+6(2) = '29'.
ELSEIF newdate+4(2) = 2.
newdate+6(2) = '28'.
ELSE.
newdate+6(2) = '30'.
ENDIF.
ELSEIF newdate+6(2) = '29'.
leaf = newdate(4) MOD 4.
IF leaf = 0 AND newdate+4(2) = 2.
newdate+6(2) = '29'.
ELSEIF newdate+4(2) = 2.
newdate+6(2) = '28'.
ENDIF.
ENDIF.
ENDIF. "IF TMONTHS <= BACKMONTHS.
ENDFORM. " GO_BACK_MONTHS
*&---------------------------------------------------------------------*
*& Form initial_selection *
*&---------------------------------------------------------------------*
FORM initial_selection .
SELECT k~lifnr k~ebeln p~ebelp p~elikz
FROM ekko AS k INNER JOIN ekpo AS p ON k~ebeln = p~ebeln
INTO TABLE it_ekpo WHERE k~aedat < w_aedat.
SORT it_ekpo BY lifnr.
LOOP AT it_ekpo.
MOVE-CORRESPONDING it_ekpo TO it_vendors.
ENDLOOP.
LOOP AT it_vendors.
DELETE ADJACENT DUPLICATES FROM it_vendors COMPARING lifnr.
ENDLOOP.
IF NOT it_vendors[] IS INITIAL.
SELECT l~lifnr l~name1 b~bukrs
FROM lfa1 AS l INNER JOIN lfb1 AS b ON l~lifnr = b~lifnr
INTO TABLE it_lfb1
FOR ALL ENTRIES IN it_vendors WHERE l~lifnr = it_vendors-lifnr.
ENDIF.
LOOP AT it_ekpo.
READ TABLE it_lfb1 WITH KEY lifnr = it_ekpo-lifnr.
MOVE-CORRESPONDING it_ekpo TO it_vend.
MOVE: it_lfb1-name1 TO it_vend-name1,
it_lfb1-bukrs TO it_vend-bukrs.
APPEND it_vend.
CLEAR it_vend.
ENDLOOP.
ENDFORM. " initial_selection
*&---------------------------------------------------------------------*
*& Form select_no_openitems *
*&---------------------------------------------------------------------*
FORM select_no_openitems .
LOOP AT it_vend.
ON CHANGE OF it_vend-lifnr.
CLEAR c1.
CLEAR c2.
ENDON.
ADD 1 TO c1.
IF it_vend-elikz = 'X'.
ADD 1 TO c2.
ENDIF.
AT END OF lifnr.
IF c1 = c2.
READ TABLE it_vend INDEX sy-tabix.
MOVE-CORRESPONDING it_vend TO it_block.
APPEND it_block.
CLEAR it_block.
ENDIF.
ENDAT.
ENDLOOP.
ENDFORM. " select_no_openitems
*&---------------------------------------------------------------------*
*& Form display_initial_selection *
*&---------------------------------------------------------------------*
FORM display_initial_selection .
tot_rec = 0.
FORMAT COLOR 2.
LOOP AT it_block.
WRITE:/ '|',5 it_block-cbox AS CHECKBOX,
10 it_block-lifnr, 21 '|',
22 it_block-name1, 53 '|',
54 it_block-bukrs, 58 '|',
59 it_block-ebeln, 70 '|',
71 it_block-ebelp, 77 '|',
78 it_block-elikz, 87 '|'.
ADD 1 TO tot_rec.
ENDLOOP.
FORMAT RESET.
ULINE (87).
ENDFORM. " display_initial_selection
*&---------------------------------------------------------------------*
*& Form TOP-OF-PAGE *
*&---------------------------------------------------------------------*
FORM top-of-page .
WRITE: /30 'VENDORS WHO CAN BE BLOCKED' COLOR 6.
ULINE.
FORMAT COLOR 5 INVERSE INTENSIFIED.
WRITE:/ 'PROG.NAME:',sy-repid, AT 40 'Company Name: GTECH',
AT 70 'User:',
sy-uname(6),
/ 'Date:',sy-datum,AT 40 'Time:',sy-uzeit, AT 70 'PageNo:',
sy-pagno.
ULINE.
FORMAT RESET.
SKIP.
ULINE (87).
FORMAT COLOR 1.
WRITE:/ '|', 5 'PICK',
10 'VENDOR',21 '|',
22 'NAME OF THE VENDOR',53 '|',
54 'CO.CODE',58 '|',
59 'PO NUBER',70 '|',
71 'ITEM NO',77 '|',
78 'DELV IND' ,87 '|'.
FORMAT RESET.
ULINE (87).
ENDFORM. " top-of-page
*&---------------------------------------------------------------------*
*& Form top_of_page_for_second_list *
*&---------------------------------------------------------------------*
FORM top_of_page_for_second_list .
WRITE: /30 'VENDORS TO BE BLOCKED' COLOR 6.
ULINE.
FORMAT COLOR 1.
WRITE: /5 'VENDOR',16 '|',
17 'CO.CODE',22 '|',
23 'DEL.FLAG ALL AREAS',41 '|',
42 'DEL.FLAG SEL.CO.COD',62 '|',
63 'DEL.FLAG GEN.DATA',83 '|',
84 'DEL FLAG SEL.CO.COD',103'|'.
FORMAT RESET.
ULINE.
ENDFORM. " top_of_page_for_second_list
*&---------------------------------------------------------------------*
*& Form select_all *
*&---------------------------------------------------------------------*
FORM select_all .
l_no = 7.
DO.
READ LINE l_no FIELD VALUE
it_block-cbox it_block-lifnr it_block-bukrs.
IF sy-subrc NE 0.
EXIT.
ENDIF.
MODIFY LINE l_no OF CURRENT PAGE FIELD VALUE it_block-cbox FROM 'X'
.
ADD 1 TO l_no.
ENDDO.
ENDFORM. " select_all
*&---------------------------------------------------------------------*
*& Form deselect_all *
*&---------------------------------------------------------------------*
FORM deselect_all .
l_no = 7.
DO.
READ LINE l_no FIELD VALUE
it_block-cbox it_block-lifnr it_block-bukrs.
IF sy-subrc NE 0.
EXIT.
ENDIF.
MODIFY LINE l_no FIELD VALUE it_block-cbox FROM ' ' .
ADD 1 TO l_no.
ENDDO.
ENDFORM. " deselect_all
*&---------------------------------------------------------------------*
*& Form final_selection *
*&---------------------------------------------------------------------*
FORM final_selection .
l_no = 10.
REFRESH it_select.
DO tot_rec TIMES.
READ LINE l_no FIELD VALUE
it_block-cbox it_block-lifnr it_block-bukrs.
IF sy-subrc NE 0.
EXIT.
ENDIF.
IF it_block-cbox = 'X'.
MOVE: it_block-lifnr TO it_select-lifnr_001,
it_block-bukrs TO it_select-bukrs_002,
' ' TO it_select-loevm_003,
'X' TO it_select-loevm_004,
' ' TO it_select-nodel_005,
'X' TO it_select-nodel_006.
APPEND it_select.
CLEAR it_select.
ENDIF.
ADD 1 TO l_no.
ENDDO.
ENDFORM. " final_selection
*&---------------------------------------------------------------------*
*& Form display_final_selection *
*&---------------------------------------------------------------------*
FORM display_final_selection .
SET PF-STATUS 'RAM1'.
FORMAT COLOR 2.
LOOP AT it_select.
WRITE: /5 it_select-lifnr_001,16 '|',
17 it_select-bukrs_002,22 '|',
23 it_select-loevm_003,41 '|',
42 it_select-loevm_004,62 '|',
63 it_select-nodel_005,83 '|',
84 it_select-nodel_006,103 '|'.
ENDLOOP.
FORMAT RESET.
ENDFORM. " display_final_selection
*&---------------------------------------------------------------------*
*& Form run_bdc *
*&---------------------------------------------------------------------*
FORM run_bdc .
DATA bdcmsgcoll LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA v_msg(150).
LOOP AT it_select.
PERFORM bdc_dynpro USING 'SAPMF02K' '0500'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-BUKRS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF02K-LIFNR'
it_select-lifnr_001.
PERFORM bdc_field USING 'RF02K-BUKRS'
it_select-bukrs_002.
PERFORM bdc_dynpro USING 'SAPMF02K' '0520'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-NODEL'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPDA'.
PERFORM bdc_field USING 'LFA1-LOEVM'
it_select-loevm_003.
PERFORM bdc_field USING 'LFB1-LOEVM'
it_select-loevm_004.
PERFORM bdc_field USING 'LFA1-NODEL'
it_select-nodel_005.
PERFORM bdc_field USING 'LFB1-NODEL'
it_select-nodel_006.
CALL TRANSACTION 'XK06' USING bdcdata
UPDATE 'S'
MODE 'E'
MESSAGES INTO bdcmsgcoll.
IF sy-subrc EQ 0.
* calling a funstion module to get the message
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
no = sy-msgno
v1 = sy-msgv1
v2 = sy-msgv2
v3 = sy-msgv3
v4 = sy-msgv4
IMPORTING
msg = v_msg.
* Printing messages
WRITE:/10 v_msg.
ENDIF.
REFRESH bdcdata.
ENDLOOP.
ENDFORM. " run_bdc
*&---------------------------------------------------------------------*
*& FORM BDC_DYNPRO *
*&---------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "BDC_DYNPRO
*&---------------------------------------------------------------------*
*& FORM BDC_FIELD *
*&---------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. "BDC_FIELD
*&---------------------------------------------------------------------*
*& Form disply_all_vendors *
*&---------------------------------------------------------------------*
FORM disply_all_vendors .
FORMAT COLOR 1.
WRITE: /2 'VENDOR NO', 14 '|',
15 'CO.CODE', 20 '|',
21 'PO NUMBER', 32 '|',
33 'ITEM NO', 38 '|',
39 'DEL.IND', 46 '|'.
FORMAT RESET.
FORMAT COLOR 2.
LOOP AT it_vend.
WRITE: /2 it_vend-lifnr, 14 '|',
15 it_vend-bukrs, 20 '|',
21 it_vend-ebeln, 32 '|',
33 it_vend-ebelp, 38 '|',
39 it_vend-elikz, 46 '|'.
ENDLOOP.
FORMAT RESET.
ENDFORM. " disply_all_vendors
‎2008 May 05 11:41 AM
hi check this..there is no command in the alv with hide ..but you can use this field for hiding fields ...for interactive alv there is no reqirement for the hide statement in alv ....but you can do it with user command
If you are creating the Field catalog manually,
then while creating the field catalog for the column which you want to hide write the following line:
gs_fieldcat-fieldname = 'Column Name'.
gs_fieldcat-no_out = 'X'.
append gs_fieldcat to gt_fieldcat.
If are using REUSE_ALV_FIELDCATALOG_MERGE for field catalog:
loop at gt_fieldcat into gs_fieldcat.
if gs_fieldcat-fieldname = 'Column name'.
gs_fieldcat-no_out = 'X'.
append gs_fieldcat to gt_fieldcat.
endif.
endloop.
regards,
venkat.
‎2008 May 05 11:52 AM
Hi,
slis_selfield is used to hole the value.
.
REPORT ZDE_INTERACTIVEALV line-count 5(2).
tables: vbak, vbap.
type-pools: slis.
types: begin of ty_vbak,
vbeln type vbeln,
kunnr type kunnr,
date type audat,
end of ty_vbak.
types: begin of ty_vbap,
matnr type matnr,
end of ty_vbap.
DATA : i_list_top_of_page TYPE slis_t_listheader.
data: i_vbak type table of ty_vbak,
i_vbap type table of ty_vbap.
data: w_vbak type ty_vbak,
w_vbap type ty_vbap.
data : i_fieldcat type slis_t_fieldcat_alv,
w_fieldcat type slis_fieldcat_alv,
i_fieldcat1 type slis_t_fieldcat_alv,
w_fieldcat1 type slis_fieldcat_alv,
i_event type slis_t_event with header line.
data: w_layout TYPE slis_layout_alv,
i_excluding TYPE slis_t_extab,
w_excluding TYPE slis_extab.
selection-screen begin of block b1.
select-options: cust for vbak-kunnr.
selection-screen end of block b1.
select vbeln from vbak into table i_vbak where kunnr in cust.
perform fieldcat.
perform event.
perform display.
form display.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_USER_COMMAND = 'CLICK'
IT_FIELDCAT = i_fieldcat
IT_EVENTS = i_event[]
TABLES
t_outtab = i_vbak[].
endform. " display
form fieldcat .
w_fieldcat-fieldname = 'VBELN'.
w_fieldcat-tabname = 'i_vbak'.
w_fieldcat-ref_fieldname = 'VBELN'.
w_fieldcat-seltext_m = 'Doc no'.
append w_fieldcat to i_fieldcat.
clear w_fieldcat.
endform. " fieldcat
form event .
i_event-name = 'USER_COMMAND'.
i_event-form = 'CLICK'.
APPEND i_event.
endform. " event
FORM CLICK USING V_UCOMM LIKE SY-UCOMM HIDEV TYPE slis_selfield.
SELECT MATNR FROM VBAP INTO TABLE I_VBAP WHERE VBELN = HIDEV-value.
perform layout.
perform fieldcat1.
PERFORM GRID.
ENDFORM.
form GRID .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = I_FIELDCAT1
IT_EXCLUDING = i_excluding
TABLES
t_outtab = i_vbap[].
endform. " GRID
form fieldcat1 .
CLEAR I_FIELDCAT1[].
w_fieldcat1-fieldname = 'MATNR'.
w_fieldcat1-tabname = 'I_VBAP'.
w_fieldcat1-seltext_m = 'Material No'.
append w_fieldcat1 to i_fieldcat1.
clear w_fieldcat1.
endform. " fieldcat1
I think it is useful for you.
‎2008 May 05 12:00 PM
‎2008 Jul 25 4:17 AM