Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

alv

Former Member
0 Kudos

Hi Abapers,

I have displayed one ALV. my requirement is : when the user selects records in ALV and clicks on ARCHIVE option which is available in menu-> Extras---> ARCHIVE, these recors should be deleted from ALV as well as table YSHELFLIFE and should get added to another table YSHELFLIFE_ARCHIVE which is a replica of table YSHELFLIFE.

the function code for ARCHIVE is 'ARCH'.

what should i code in order to accomplish this functionality.

kindly help me.

thanks in advance,

Radhi.

1 REPLY 1

Former Member
0 Kudos

Hi!

You have to check the user command of your ALV, then add here your coding. Check out the following example.

REPORT YPBC_ALV_INTERACTIVE .

TABLES: KNA1,VBAP,VBAK.

TYPE-POOLS:SLIS.

SELECT-OPTIONS: CUSTOMER FOR KNA1-KUNNR.

DATA: BEGIN OF ITAB OCCURS 50,

KUNNR LIKE KNA1-KUNNR,

NAME1 LIKE KNA1-NAME1,

END OF ITAB.

DATA: BEGIN OF JTAB OCCURS 50,

VBELN LIKE VBAK-VBELN,

NETWR LIKE VBAK-NETWR,

END OF JTAB.

DATA: BEGIN OF KTAB OCCURS 50,

POSNR LIKE VBAP-POSNR,

MATNR LIKE VBAP-MATNR,

END OF KTAB.

DATA: F_KNA1 TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

F_VBAK TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

F_VBAP TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

F_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE.

PERFORM GET_VAL.

*&----


*

*& Form GET_VAL

*&----


*

  • text

*----


*

FORM GET_VAL.

F_KNA1-FIELDNAME = 'KUNNR'.

F_KNA1-REF_TABNAME = 'KNA1'.

F_KNA1-EMPHASIZE = 'C611'.

F_KNA1-HOTSPOT = 'X'.

APPEND F_KNA1.

F_KNA1-FIELDNAME = 'NAME1'.

F_KNA1-REF_TABNAME = 'KNA1'.

APPEND F_KNA1.

F_VBAK-FIELDNAME = 'VBELN'.

F_VBAK-REF_TABNAME = 'VBAK'.

APPEND F_VBAK.

F_VBAK-FIELDNAME = 'NETWR'.

F_VBAK-REF_TABNAME = 'VBAK'.

APPEND F_VBAK.

F_VBAP-FIELDNAME = 'POSNR'.

F_VBAP-REF_TABNAME = 'VBAP'.

APPEND F_VBAP.

F_VBAP-FIELDNAME = 'MATNR'.

F_VBAP-REF_TABNAME = 'VBAP'.

APPEND F_VBAP.

F_EVENTS-NAME = 'USER_COMMAND'.

F_EVENTS-FORM = 'VAL'.

APPEND F_EVENTS.

ENDFORM. "GET_VAL

START-OF-SELECTION.

SELECT KUNNR NAME1 FROM KNA1 INTO TABLE ITAB WHERE KUNNR IN CUSTOMER.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-CPROG

I_STRUCTURE_NAME = 'ITAB'

IT_FIELDCAT = F_KNA1[]

IT_EVENTS = F_EVENTS[]

TABLES

T_OUTTAB = ITAB.

*

**&----


*

**& Form VAL

**&----


*

    • text

**----


*

    • -->USER_COMMANtext

    • -->CURSOR text

**----


*

FORM VAL USING USER_COMMAND LIKE SY-UCOMM CURSOR TYPE SLIS_SELFIELD.

DATA: CUST(10) TYPE N,

SEL(10) TYPE N,

MATN(10) TYPE C.

IF CURSOR-FIELDNAME = 'KUNNR'.

CUST = CURSOR-VALUE.

SELECT VBELN NETWR FROM VBAK INTO TABLE JTAB WHERE KUNNR = CUST.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

I_STRUCTURE_NAME = 'JTAB'

IT_FIELDCAT = F_VBAK[]

IT_EVENTS = F_EVENTS[]

TABLES

T_OUTTAB = JTAB.

ENDIF.

Regards

Tamá