Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

EDITABLE ALV

Hello Friends,

I am struggling with this. I have tried all the possiblities as

suggested on this forum in the past but havent suceeded.

I have developed an Editable ALV list using (RESEU ALV LIST DISPLAY) report and everything works fine.

It has a Material column and is the editable column. Once the user enters

Naterial # or changes existing material # into this column and hits enter it does some validations. After the validations the curson remains on the same line. The user wants the curson on the next line.

How can this be done.

I have tried to get this with the GET CURSOR, SET Cursor, looked at

the sameple codes DEMO_DYNPRO_GET_CURSOR

DEMO_DYNPRO_SET_CURSOR

but am uncusseful.

I have pasted a sample code and is editable. Can anyone change it to my requirement or have a sample program to acheive this.

Thanks in Advance,

Ster.

REPORT ZSTER.

TYPE-POOLS: KKBLO,
            SLIS.

TABLES: MARA, MARC, MARD.

DATA:       DISVARIANT   LIKE DISVARIANT,
            EVENTCAT     TYPE SLIS_T_EVENT,
            EVENTCAT_LN  LIKE LINE OF EVENTCAT,
            FIELDCAT     TYPE SLIS_T_FIELDCAT_ALV,
            FIELDCAT_KKB TYPE KKBLO_T_FIELDCAT,
            FIELDCAT_LN  LIKE LINE OF FIELDCAT,
            KEYINFO      TYPE SLIS_KEYINFO_ALV,
            LAYOUT       TYPE SLIS_LAYOUT_ALV,
            LAYOUT_KKB   TYPE KKBLO_LAYOUT,
            PGM          LIKE SY-REPID,
            PRINTCAT     TYPE SLIS_PRINT_ALV,
            SORTCAT      TYPE SLIS_T_SORTINFO_ALV,
            SORTCAT_LN   LIKE LINE OF SORTCAT,

            BEGIN OF COLTAB OCCURS 50,
              FIELDNAME LIKE FIELDCAT_LN-FIELDNAME,
            END OF COLTAB.

DATA: PRINT          TYPE SLIS_PRINT_ALV.

DATA : V_REPID TYPE SY-REPID.

DATA: BEGIN OF WA OCCURS 0,
*        CHECKBOX(1),
        MATNR TYPE MARA-MATNR,
        ERSDA TYPE MARA-ERSDA,
        ERNAM TYPE MARA-ERNAM,
        AENAM TYPE MARA-AENAM,
        WERKS TYPE MARC-WERKS,
        PSTAT TYPE MARC-PSTAT,
        LFMON TYPE MARD-LFMON,
      END OF WA.

DATA: BEGIN OF ITAB OCCURS 0,
        CHECKBOX(1),
        MATNR TYPE MARA-MATNR,
        ERSDA TYPE MARA-ERSDA,
        ERNAM TYPE MARA-ERNAM,
        AENAM TYPE MARA-AENAM,
        WERKS TYPE MARC-WERKS,
        PSTAT TYPE MARC-PSTAT,
        LFMON TYPE MARD-LFMON,
END OF ITAB.

DATA: W_TABNAME     TYPE SLIS_LINEINFO-TABNAME.

**Selection Screen

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001..
SELECT-OPTIONS: MAT_NO FOR MARA-MATNR.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK B1.
* Parameter for list viewer display variant

PARAMETERS:    VARIANT  LIKE DISVARIANT-VARIANT.
PARAMETERS:    P_PRINT TYPE CHECKBOX.

AT SELECTION-SCREEN ON VARIANT.
  CHECK NOT VARIANT IS INITIAL.

*Initialization
INITIALIZATION.
  V_REPID = SY-REPID.

*Start of selection

START-OF-SELECTION.
  SELECT A~MATNR A~ERSDA
         A~ERNAM A~AENAM
         C~WERKS C~PSTAT D~LFMON
  INTO TABLE WA
  UP TO 3 ROWS
  FROM MARA AS A
  INNER JOIN MARC AS C ON A~MATNR = C~MATNR
  INNER JOIN MARD AS D ON C~MATNR = D~MATNR
  WHERE A~MATNR IN MAT_NO.

  ITAB[] = WA[].

*End of Selection
END-OF-SELECTION.
  PERFORM CALL_LIST_VIEWER.

*&---------------------------------------------------------------------*
*&      Form  call_list_viewer
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM CALL_LIST_VIEWER .

  PERFORM BUILD_FIELDCAT USING:
           'CHECKBOX' 'ITAB'
            'CHK BOX' 'CHAR'         3 ' ' ' ' ' ' ' ' ' ' 'X' ' ' 'X',
           'MATNR' 'ITAB'
            'Material #' 'CHAR'     18 ' ' ' ' ' ' ' ' ' ' 'X' ' ' ' ',
           'ERSDA' 'ITAB'
            'Date Created' 'CHAR'   10 ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ',
           'ERNAM' 'ITAB'
            'Created By' 'CHAR'     10 ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ',
           'AENAM' 'ITAB'
            'Changed By' 'CHAR'     10 ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ',
           'WERKS' 'ITAB'
            'Plant' 'CHAR'           4 ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ',
           'PSTAT' 'ITAB'
            'Status' 'CHAR'         10 ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ',
           'LFMON' 'ITAB'
            'Current Period' 'CHAR'  8 ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '.

  PERFORM BUILD_EVENTCAT USING: 'TOP_OF_LIST',
                                'TOP_OF_PAGE',
                                'BEFORE_LINE_OUTPUT'.

  PERFORM LIST_DISPLAY TABLES ITAB.

ENDFORM.                    "call_list_viewer

*----------------------------------------------------------------------*
* build field catalog entry                                            *
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT USING A_FIELDNAME
                          A_TABNAME
                          A_HEADING
                          A_DATATYPE
                          A_OUTPUTLEN
                          A_KEY
                          A_NO_OUT
                          A_NO_SUM
                          A_DO_SUM
                          A_NO_ZERO
                          A_INPUT
                          A_SUM
                          A_CHECKBOX.                          .


  CLEAR FIELDCAT_LN.
  FIELDCAT_LN-FIELDNAME = A_FIELDNAME.
  FIELDCAT_LN-TABNAME  = A_TABNAME.
  FIELDCAT_LN-OUTPUTLEN = A_OUTPUTLEN.
  FIELDCAT_LN-DATATYPE = A_DATATYPE.
  FIELDCAT_LN-REPTEXT_DDIC = A_HEADING.
  FIELDCAT_LN-KEY = A_KEY.
  FIELDCAT_LN-NO_OUT = A_NO_OUT.
  FIELDCAT_LN-NO_SUM = A_NO_SUM.
  FIELDCAT_LN-DO_SUM = A_DO_SUM.
  FIELDCAT_LN-NO_ZERO = A_NO_ZERO.
  FIELDCAT_LN-INPUT = A_INPUT.
  FIELDCAT_LN-DO_SUM = A_SUM.
  FIELDCAT_LN-CHECKBOX = A_CHECKBOX.
  APPEND FIELDCAT_LN TO FIELDCAT.

ENDFORM.                    "BUILD_FIELDCAT
*----------------------------------------------------------------------*
*       FORM BUILD_EVENTCAT
*----------------------------------------------------------------------*
FORM BUILD_EVENTCAT USING A_EVENT.

  EVENTCAT_LN-NAME = EVENTCAT_LN-FORM = A_EVENT.
  APPEND EVENTCAT_LN TO EVENTCAT.

ENDFORM.                    "BUILD_EVENTCAT
*----------------------------------------------------------------------*
* call the ABAP list viewer                                            *
*----------------------------------------------------------------------*
FORM LIST_DISPLAY TABLES A_OUTPUT.

  PGM = DISVARIANT-REPORT = SY-REPID.
  DISVARIANT-VARIANT = VARIANT.
* call list viewer
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM       = PGM
      I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
      IT_FIELDCAT              = FIELDCAT
      IS_VARIANT               = DISVARIANT
      IS_LAYOUT                = LAYOUT
      IS_PRINT                 = PRINT
      I_SAVE                   = 'A'
      IT_EVENTS                = EVENTCAT
      IT_SORT                  = SORTCAT
      I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
    TABLES
      T_OUTTAB                 = A_OUTPUT
    EXCEPTIONS
      PROGRAM_ERROR            = 1
      OTHERS                   = 2.

ENDFORM.                    "LIST_DISPLAY
**---------------------------------------------------------------------*
** FORM SET_PF_STATUS *
**---------------------------------------------------------------------*

FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
  SET PF-STATUS 'ZASH'.
ENDFORM.                    "set_pf_status

**---------------------------------------------------------------------*
** FORM USER_COMMAND *
**---------------------------------------------------------------------*

FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.

  DATA LAYOUT TYPE SLIS_LAYOUT_ALV.

  CASE UCOMM.

    WHEN 'ENT1'.

      SCROLL LIST TO PAGE 1 LINE SY-LILLI.
      SY-LILLI = SY-LILLI + 1.
      SET CURSOR LINE SY-LILLI OFFSET 2.

    WHEN '&IC1'.
      READ TABLE ITAB INDEX SELFIELD-TABINDEX.

      SET PARAMETER ID 'MAT' FIELD ITAB-MATNR.
      CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.

    WHEN 'COPY'.
      LOOP AT ITAB.
        IF ITAB-CHECKBOX = 'X'.
          INSERT ITAB INTO ITAB INDEX SY-TABIX.
        ENDIF.
      ENDLOOP.

  ENDCASE.

ENDFORM.                    "USER_COMMAND

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question