User-command en ALV

Colapsar
X
 
  • Tiempo
  • Mostrar
Limpiar Todo
nuevos mensajes
  • Jarpi
    Senior Member
    • abr
    • 453

    #1

    User-command en ALV

    Buen día para todos,

    Los molesto en esta oportunidad pues se me está presentando una duda que no logro destrabar.

    Estoy usando el comando i_callback_user_command para un reporte con ALV y lo que quisiera hacer es que 2 columnas tengan una rutina interna. En este caso, tengo la columna BELNR y otra con un ícono. La columna del doc. lleva al usuario a la trx FB03 y le muestra el asiento, y la otra columna muestra cuando el documento tiene Lista de Anexos.

    El problema está en que no puedo hacer que cada columna tenga su propia rutina, alguien podrá darme una mano con esto?? Alguien me dijo que cada columna debería tener distinto sy-ucomm, pero cuando lo chequeo, no es así.

    Cualquier ayuda es bienvenida.

    Muchas gracias de antemano,
    Saludos.
  • DavidXD_XD
    Moderator
    • ago
    • 1255

    #2
    Hola ... intentalo de esta forma, por ejemplo yo tengo una columna Numero de documento (BELNR) y esta relacionado con una factura (ORIGIN_DOC)

    Código:
    FORM USER_COMMAND USING r_ucomm     LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
    
      DATA: wa_alv LIKE output_table.
    
      CASE r_ucomm.
        WHEN '&IC1'.                                            "Doble Click
    [COLOR="Blue"]* El registro que se escogió debe estar definido[/COLOR]
          CHECK NOT rs_selfield-value IS INITIAL.
    [COLOR="blue"]* Determinar la linea elegida[/COLOR]
          READ TABLE output_table
                             INDEX rs_selfield-tabindex INTO wa_alv.
    [COLOR="blue"]* Si la columna es el campo BELNR (Numero de Documento)[/COLOR]
          IF rs_selfield-sel_tab_field CS 'BELNR'.
    [COLOR="blue"]* Muestro el asiento contable[/COLOR]
             SET PARAMETER ID 'BUK' FIELD wa_alv-bukrs.
             SET PARAMETER ID 'BLN' FIELD wa_alv-belnr.
             SET PARAMETER ID 'GJR' FIELD wa_alv-gjahr.
             CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
    [COLOR="blue"]* Si la columna es el campo ORIGIN_DOC (Factura)[/COLOR]
          ELSEIF rs_selfield-sel_tab_field CS 'ORIGIN_DOC'.
    [COLOR="blue"]* Muestro la factura[/COLOR]
             SET PARAMETER ID 'VF' FIELD wa_alv-origin_doc.
             CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.
          ELSE.
             MESSAGE E110 WITH rs_selfield-value.
          ENDIF.
        ENDCASE.
    
    ENDFORM.
    David Carballido Córdova

    Comentario

    • Jarpi
      Senior Member
      • abr
      • 453

      #3
      Hola DavidXD_XD,

      Era exactamente lo que necesitaba! Realmente te agradezco mucho, estaba seguro contar con una respuesta tuya, no te cansas de ayudar! Ojalá algún día pueda ayudar como vos.

      Muchas gracias nuevamente,
      Saludos.

      Comentario

      • Caraver
        Junior Member
        • nov
        • 27

        #4
        Dump al hacer doble click

        Buenas tardes, he echo la parte para que vaya a la tx vf03 y al dar doble click me da el siguiente dump:
        ************************************************** **********
        Err.tmpo.ejec. PERFORM_NOT_FOUND
        Excep. CX_SY_DYN_CALL_ILLEGAL_FORM
        Fecha y hora 17.12.2008 18:42:39

        Texto breve
        Call (PERFORM) to a non-existent routine.

        ¿Qué ha sucedido?
        There exist various options:
        Error in the ABAP Application Program

        The current ABAP program "SAPLSLVC_FULLSCREEN" had to be terminated because it
        has
        come across a statement that unfortunately cannot be executed.
        or
        Error in the SAP kernel.

        The current ABAP "SAPLSLVC_FULLSCREEN" program had to be terminated because the
        ABAP processor detected an internal system error.


        ¿Qué puede hacer?
        Note down which actions and inputs caused the error.


        To process the problem further, contact you SAP system
        administrator.

        Using Transaction ST22 for ABAP Dump Analysis, you can look
        at and manage termination messages, and you can also
        keep them for a long time.


        Anál.errores
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_FORM', was
        not caught in
        procedure "USER_COMMAND" "(FORM)", nor was it propagated by a RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        The program "SAPLSLVC_FULLSCREEN" is meant to execute an external PERFORM,
        namely the routine "USER_COMAND " of the program "ZLIST_FACT ", but
        this routine does not exist.

        This may be due to any of the following reasons:

        1. One of the programs "SAPLSLVC_FULLSCREEN" or "ZLIST_FACT " is currently
        being developed.
        The name "USER_COMAND " of the called routine may be incorrect, or
        the routine "USER_COMAND " is not yet implemented in the program "ZLIST_FACT ".
        -

        2. If the program SAPMSSY1 is involved in the runtime error, one of
        the function modules called via RFC is not flagged as remote-capable.
        (see Transaction SE37 Goto -> Administration -> RFC flag)

        3. There is an inconsistency in the system. The versions of the
        programs "SAPLSLVC_FULLSCREEN" and "ZLIST_FACT " do not match.


        Notas para corregir errores
        - Check that transports to the system are complete.
        - Conclude any developments already begun ("SAPLSLVC_FULLSCREEN" and/or
        "ZLIST_FACT ").
        - Check routine names

        If the error occures in a non-modified SAP program, you may be able to
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the following
        keywords:

        "PERFORM_NOT_FOUND" "CX_SY_DYN_CALL_ILLEGAL_FORM"
        "SAPLSLVC_FULLSCREEN" or "LSLVC_FULLSCREENF01"
        "USER_COMMAND"

        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:

        1. The description of the current problem (short dump)

        To save the description, choose "System->List->Save->Local File
        (Unconverted)".

        2. Corresponding system log

        Display the system log by calling transaction SM21.
        Restrict the time interval to 10 minutes before and five minutes
        after the short dump. Then choose "System->List->Save->Local File
        (Unconverted)".

        3. If the problem occurs in a problem of your own or a modified SAP
        program: The source code of the program
        In the editor, choose "Utilities->More
        Utilities->Upload/Download->Download".

        4. Details about the conditions under which the error occurred or which
        actions and input led to the error.

        The exception must either be prevented, caught within proedure
        "USER_COMMAND" "(FORM)", or its possible occurrence must be declared in the
        RAISING clause of the procedure.
        To prevent the exception, note the following:


        ************************************************** ****************

        Si sabéis por qué puede ser agradezco que me lo digan, llevo todo el día y no tengo npi de por que es, un saludo y gracias

        Comentario

        • DavidXD_XD
          Moderator
          • ago
          • 1255

          #5
          Hola ... en ese caso creo que lo estas trabajando con REUSE_ALV_GRID_DISPLAY, para ese caso debes pasar como parametros de entrada tanto el programa como el FORM USER_COMMAND de esta manera

          Código:
          CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
                 EXPORTING
                      I_CALLBACK_PROGRAM       = g_repid
                      I_CALLBACK_PF_STATUS_SET = 'SET_STATUS'
                      I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
                      I_CALLBACK_TOP_OF_PAGE   = 'TOP_OF_PAGE'
                      I_BACKGROUND_ID          = 'ALV_BACKGROUND'
                      IS_LAYOUT                = gs_layout
                      IT_FIELDCAT              = ti_fieldcat
                      IT_SORT                  = ti_sort
                      I_SAVE                   = 'A'
                 TABLES
                      T_OUTTAB                 = ti_bsak
                 EXCEPTIONS
                      PROGRAM_ERROR            = 1
                      OTHERS                   = 2.
          Debes comunicar a la funcion los parametros I_CALLBACK_PROGRAM y I_CALLBACK_USER_COMMAND
          David Carballido Córdova

          Comentario

          • Caraver
            Junior Member
            • nov
            • 27

            #6
            Esos dos parametros los tengo puesto, mira te paso el codigo a ver si ves algo raro:
            FORM listar .

            g_pid = sy-repid.
            CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
            EXPORTING
            * I_INTERFACE_CHECK = ' '
            * I_BYPASSING_BUFFER = ' '
            * I_BUFFER_ACTIVE = ' '
            i_callback_program = g_pid
            * i_callback_pf_status_set =
            i_callback_user_command = 'USER_COMAND '
            i_callback_top_of_page = 'f_top'
            * I_CALLBACK_HTML_TOP_OF_PAGE = ' '
            * I_CALLBACK_HTML_END_OF_LIST = ' '
            i_structure_name = 'zlist_fact'
            * I_BACKGROUND_ID = ' '
            * I_GRID_TITLE =
            * I_GRID_SETTINGS =
            * IS_LAYOUT = 'layout'
            it_fieldcat = gt_fcat[]
            * IT_EXCLUDING =
            * IT_SPECIAL_GROUPS =
            * IT_SORT =
            * IT_FILTER =
            * IS_SEL_HIDE =
            * I_DEFAULT = 'X'
            * I_SAVE = ' '
            * IS_VARIANT =
            * IT_EVENTS =
            * 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 = gt_zlist_fact
            * 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. " listar
            ************************************************** ********
            y el del user command:
            ************************************************** *********

            FORM user_command
            USING r_ucomm LIKE sy-ucomm
            rs_selfield TYPE slis_selfield.


            CASE r_ucomm.

            WHEN '&IC1'.

            * Naveg. a Pedido
            IF rs_selfield-sel_tab_field CS 'VBELN'
            AND rs_selfield-value IS NOT INITIAL.

            SET PARAMETER ID 'VF' FIELD rs_selfield-value.
            CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.

            ENDIF.
            ENDCASE.

            ENDFORM. "user_command
            Creo que esta todo bien pero me salta el dump, llevo poco tiempo haciendo listado y seguro que se me escapa algo, muchas gracas

            Comentario

            • francesc
              Member
              • mar
              • 58

              #7
              Te falta una 'M' en USER_COMMAND ,en el nombre que le pasas a la función.

              Comentario

              • Caraver
                Junior Member
                • nov
                • 27

                #8
                Muchisimas gracias, llevo 2 días dandome cabezasos, y estoy seguro que no lo hubiera visto, muchas gracias de nuevo

                Comentario

                • Abaunus
                  Senior Member
                  • nov
                  • 119

                  #9
                  Originalmente publicado por DavidXD_XD
                  Hola ... en ese caso creo que lo estas trabajando con REUSE_ALV_GRID_DISPLAY, para ese caso debes pasar como parametros de entrada tanto el programa como el FORM USER_COMMAND de esta manera

                  Código:
                  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
                         EXPORTING
                              I_CALLBACK_PROGRAM       = g_repid
                              I_CALLBACK_PF_STATUS_SET = 'SET_STATUS'
                              I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
                              I_CALLBACK_TOP_OF_PAGE   = 'TOP_OF_PAGE'
                              I_BACKGROUND_ID          = 'ALV_BACKGROUND'
                              IS_LAYOUT                = gs_layout
                              IT_FIELDCAT              = ti_fieldcat
                              IT_SORT                  = ti_sort
                              I_SAVE                   = 'A'
                         TABLES
                              T_OUTTAB                 = ti_bsak
                         EXCEPTIONS
                              PROGRAM_ERROR            = 1
                              OTHERS                   = 2.
                  Debes comunicar a la funcion los parametros I_CALLBACK_PROGRAM y I_CALLBACK_USER_COMMAND

                  Hola David, veo que la tenés clara, te hago dos consultas:
                  Yo creo los ALV con esa función 'REUSE_ALV_GRID_DISPLAY', pero el único Callback que hago es I_CALLBACK_PROGRAM, ya que los otros los cargo con it_events... ¿cuál es la diferencia?
                  La otra cosnulta es: ¿cuál es la otra función para los ALV?
                  Desde ya, gracias,
                  Saludos

                  Comentario

                  • DavidXD_XD
                    Moderator
                    • ago
                    • 1255

                    #10
                    Hola, bueno hasta donde se el REUSE_ALV_GRID_DISPLAY es un tipo de framework y tbm hace uso de un contenedor y realiza la insercion de datos con objetos, cuando he debuggeado el I_CALLBACK_PROGRAM nos sirve para poder direccionar las subrutinas que se crean para los eventos dentro del framework, x ejm, dentro del codigo existe algo asi

                    Código:
                    PERFORM (i_callback_user_command) IN PROGRAM (i_callback_program) IF FOUND.
                    Por eso es necesario transmitir el nombre del programa dentro de la funcion, asi como tambien el evento user command dentro del parametro i_callback_user_command y tbm pasa los mismo con el parametro I_CALLBACK_PF_STATUS_SET, I_CALLBACK_TOP_OF_PAGE para los eventos de menu de barra y cabecera ... los demas eventos que no se especifican como por ejemplo el pie de pagina se trabaja con la tabla de eventos, espero te sirva la info

                    PD: Si toy ekivocado xfas corregirme
                    David Carballido Córdova

                    Comentario

                    • Abaunus
                      Senior Member
                      • nov
                      • 119

                      #11
                      Claro, eso que aclarás lo entiendo. Lo que quería decir es que los eventos user command, top of page y status yo no los cargo en la llamada de función con los callback, como pusiste vos, sino directamente con la tabla it_events... no sé si me explico...
                      La otra consulta es si no se genera el ALV con esa función, cuál es la que usás vos... (sin considerar Objects).

                      Mil gracias por todo.
                      Saludos

                      Comentario

                      • DavidXD_XD
                        Moderator
                        • ago
                        • 1255

                        #12
                        Con el REUSE_ALV_GRID_DISPLAY hay q llenar los parametro porq creo q no hace caso a los eventos que se coloca en la tabla interna de eventos, pero esos si sirven con una Lista con el MF REUSE_ALV_LIST_DISPLAY (Se esta volviendo obsoleto) y otras formas de usar el ALV es con un jerarquico con la funcion REUSE_ALV_HIERSEQ_LIST_DISPLAY, por bloques con
                        REUSE_ALV_BLOCK_LIST_APPEND
                        REUSE_ALV_BLOCK_LIST_DISPLAY
                        El append para agregar los bloques y el display para colocarlos en pantalla, y tbm el REUSE_ALV_TREE_DISPLAY_OM ... esos son los que he usado hasta el momento
                        David Carballido Córdova

                        Comentario

                        • Abaunus
                          Senior Member
                          • nov
                          • 119

                          #13
                          Mil gracias David, ahora estoy estudiando esa forma de hacer ALVs en bloque, gracias.
                          Por otro lado, con la REUSE_ALV_GRID_DISPLAY yo cargo los eventos en la it_events y funciona perfecto, poniendo sólo el callback...
                          Ya con los REUSE_ALV_BLOCK_LIST no funciona de ese modo, hay que hacer los callbacks...

                          Comentario

                          Trabajando...