Múltiple elección

Colapsar
X
 
  • Tiempo
  • Mostrar
Limpiar Todo
nuevos mensajes
  • Flatron
    Member
    • ago
    • 78

    #1

    Múltiple elección

    Me estoy rompiendo la cabeza con esto,

    Tengo el siguiente código, que tengo que modificar para que en vez de introducir un sólo número de documento me active el poder meter varios.


    *** programa que calcula por posición el flujo de documentos ****

    *---- Selection Screen -------------------------------------------------
    parameters: vbeln like vbuk-vbeln memory id aun obligatory,
    posnr like vbap-posnr memory id pid.
    *---- Variables --------------------------------------------------------
    data: w_comwa like vbco6,
    it_doc like vbfa occurs 0 with header line,
    it_txt like dd07v occurs 0 with header line,
    begin of it_type occurs 0,
    vbtyp like vbuk-vbtyp,
    text like dd07v-ddtext,
    end of it_type.
    *-----------------------------------------------------------------------
    start-of-selection.
    w_comwa-mandt = sy-mandt.
    w_comwa-vbeln = vbeln.
    w_comwa-posnr = posnr.
    call function 'RV_ORDER_FLOW_INFORMATION'
    exporting
    comwa = w_comwa
    tables
    vbfa_tab = it_doc
    exceptions
    no_vbfa = 1
    no_vbuk_found = 2
    others = 3.
    case sy-subrc.
    when 1. write: / 'No VBFA found.'.
    when 2. write: / 'No VBUK found. Check selection criteria...'.
    when 3. write: / 'Unknown Error!'.
    when 0. perform write_docs.
    endcase.
    *-----------------------------------------------------------------------
    form write_docs.
    call function 'GET_DOMAIN_VALUES'
    exporting
    domname = 'VBTYP'
    tables
    values_tab = it_txt
    exceptions
    no_values_found = 1
    others = 2.
    case sy-subrc.
    when 1. write: / 'Warning: No texts found for Sales Docs types!'.
    when 2. write: / 'Warning: Cannot retrieve SD types descriptions!'.
    when 0. perform sort_texts.
    endcase.

    write: / 'Order Flow Information:'.
    loop at it_doc.
    write: / it_doc-stufe,
    it_doc-vbelv,
    it_doc-posnv.
    perform write_type using it_doc-vbtyp_v.
    write: it_doc-vbeln,
    it_doc-posnn.
    perform write_type using it_doc-vbtyp_n.
    write: it_doc-matnr,
    it_doc-rfmng unit it_doc-meins,
    it_doc-meins.
    endloop.
    endform.
    *-----------------------------------------------------------------------
    form sort_texts.
    loop at it_txt.
    it_type-vbtyp = it_txt-domvalue_l.
    it_type-text = it_txt-ddtext.
    append it_type.
    clear it_type.
    endloop.
    sort it_type.
    endform.
    *-----------------------------------------------------------------------
    form write_type using value(p_vbtyp) like vbuk-vbtyp.
    data w_txt(30) type c.
    read table it_type with key vbtyp = p_vbtyp binary search.
    case sy-subrc.
    when 0. w_txt = it_type-text.
    when others. w_txt = '?'.
    endcase.
    write w_txt intensified off.
    endform.
    *-----------------------------------------------------------------------
  • beltsoft
    Member
    • sep
    • 99

    #2
    SELECT-OPTIONS vbeln for vbuk-vbeln memory id aun obligatory.

    No olvides declar la tabla.

    Saludos.
    SSE BeltSoft México
    Your Business, our motivation ...

    Comentario

    • Flatron
      Member
      • ago
      • 78

      #3
      Si declaro la tabla, y añado esa instrucción me dice que el campo vbeln ya ha sido definido ...

      Comentario

      • esterg
        Junior Member
        • sep
        • 20

        #4
        sustituir parameter- select options

        Hola,
        -Cuando te da el mensaje te indica donde es el segundo lugar que esta definido ??
        -La idea es sustituir el parameter por select options.
        Si es otra cosa distinta, despues comentalo.
        Suerte,
        Ester.-

        Comentario

        • Flatron
          Member
          • ago
          • 78

          #5
          Si sustituyo el parameters por el select-options, me llega al final a decir que la tabla VBUK no la encuentra.

          Comentario

          • Flatron
            Member
            • ago
            • 78

            #6
            Quería decir Aunque la defina en tables, me salta al error 2, cuando si dejo el parameters si llega.

            start-of-selection.
            w_comwa-mandt = sy-mandt.
            w_comwa-vbeln = vbeln.
            w_comwa-posnr = posnr.
            call function 'RV_ORDER_FLOW_INFORMATION'
            exporting
            comwa = w_comwa
            tables
            vbfa_tab = it_doc
            exceptions
            no_vbfa = 1
            no_vbuk_found = 2
            others = 3.
            case sy-subrc.
            when 1. write: / 'No VBFA found.'.
            when 2. write: / 'No VBUK found. Check selection criteria...'.
            when 3. write: / 'Unknown Error!'.
            when 0. perform write_docs.
            endcase.

            Comentario

            • esterg
              Junior Member
              • sep
              • 20

              #7
              Problema con nombre de parametro

              Hola,
              No tengo aca SAP para probar.
              Yo al select-option: lo nombraria p_vbeln y definiria la tabla vbuk.
              Tambien fijate que el select option no se usa igual que un parametro, que es un solo valor.
              Espero que esto se sirva.
              Suerte.Ester.-

              Comentario

              • Flatron
                Member
                • ago
                • 78

                #8
                Gracias esterg por tus comentarios.

                Dices que lo ponga así??

                Así el problema que tengo es que siempre me coge el caso 2.
                when 2. write: / 'No VBUK found. Check selection criteria...'.

                tables: vbuk,vbap.

                select-options: p_vbeln for vbuk-vbeln memory id aun obligatory.

                parameters: posnr like vbap-posnr memory id pid.

                **
                *---- Variables --------------------------------------------------------
                data: w_comwa like vbco6,
                it_doc like vbfa occurs 0 with header line,
                it_txt like dd07v occurs 0 with header line,
                begin of it_type occurs 0,
                vbtyp like vbuk-vbtyp,
                text like dd07v-ddtext,
                end of it_type.
                *-----------------------------------------------------------------------
                start-of-selection.
                w_comwa-mandt = sy-mandt.
                w_comwa-vbeln = p_vbeln.
                w_comwa-posnr = posnr.
                call function 'RV_ORDER_FLOW_INFORMATION'
                exporting
                comwa = w_comwa
                tables
                vbfa_tab = it_doc
                exceptions
                no_vbfa = 1
                no_vbuk_found = 2
                others = 3.
                case sy-subrc.
                when 1. write: / 'No VBFA found.'.
                when 2. write: / 'No VBUK found. Check selection criteria...'.
                when 3. write: / 'Unknown Error!'.
                when 0. perform write_docs.
                endcase.
                *-----------------------------------------------------------------------
                form write_docs.
                call function 'GET_DOMAIN_VALUES'
                exporting
                domname = 'VBTYP'
                tables
                values_tab = it_txt
                exceptions
                no_values_found = 1
                others = 2.
                case sy-subrc.
                when 1. write: / 'Warning: No texts found for Sales Docs types!'.
                when 2. write: / 'Warning: Cannot retrieve SD types descriptions!'.
                when 0. perform sort_texts.
                endcase.

                write: / 'Order Flow Information:'.
                loop at it_doc.
                write: / it_doc-stufe,
                it_doc-vbelv,
                it_doc-posnv.
                perform write_type using it_doc-vbtyp_v.
                write: it_doc-vbeln,
                it_doc-posnn.
                perform write_type using it_doc-vbtyp_n.
                write: it_doc-matnr,
                it_doc-rfmng unit it_doc-meins,
                it_doc-meins.
                endloop.
                endform.
                *-----------------------------------------------------------------------
                form sort_texts.
                loop at it_txt.
                it_type-vbtyp = it_txt-domvalue_l.
                it_type-text = it_txt-ddtext.
                append it_type.
                clear it_type.
                endloop.
                sort it_type.
                endform.
                *-----------------------------------------------------------------------
                form write_type using value(p_vbtyp) like vbuk-vbtyp.
                data w_txt(30) type c.
                read table it_type with key vbtyp = p_vbtyp binary search.
                case sy-subrc.
                when 0. w_txt = it_type-text.
                when others. w_txt = '?'.
                endcase.
                write w_txt intensified off.
                endform.

                Comentario

                • DCErick
                  Moderator
                  • mar
                  • 1090

                  #9
                  Originalmente publicado por Flatron
                  Quería decir Aunque la defina en tables, me salta al error 2, cuando si dejo el parameters si llega.

                  start-of-selection.
                  w_comwa-mandt = sy-mandt.
                  w_comwa-vbeln = vbeln.
                  w_comwa-posnr = posnr.
                  call function 'RV_ORDER_FLOW_INFORMATION'
                  exporting
                  comwa = w_comwa
                  tables
                  vbfa_tab = it_doc
                  exceptions
                  no_vbfa = 1
                  no_vbuk_found = 2
                  others = 3.
                  case sy-subrc.
                  when 1. write: / 'No VBFA found.'.
                  when 2. write: / 'No VBUK found. Check selection criteria...'.
                  when 3. write: / 'Unknown Error!'.
                  when 0. perform write_docs.
                  endcase.
                  Es porque al asignar w_comwa-vbeln = vbeln. le estas asignando la cabecera del rango vbeln al campo w_comwa-vbeln. La funcion quer estas usando (RV_ORDER_FLOW_INFORMATION) te regresa el flujo de documentos de un solo pedido.

                  Lo que deberias hacer es declararte una tabla interna para seleccionar los pedidos que estén en el rango que indicaste, luego aplicarle un loop a esa tabla interna para ver el flujo de docuemtos de cada pedido seleccionado.

                  Código:
                  loop at ti_pedidos into wa_pedido.
                  w_comwa-mandt = sy-mandt.
                  w_comwa-vbeln = wa_pedido-vbeln.
                  w_comwa-posnr = posnr.
                  call function 'RV_ORDER_FLOW_INFORMATION'
                  exporting
                  comwa = w_comwa
                  tables
                  vbfa_tab = it_doc
                  exceptions
                  no_vbfa = 1
                  no_vbuk_found = 2
                  others = 3.
                  case sy-subrc.
                  when 1. write: / 'No VBFA found.'.
                  when 2. write: / 'No VBUK found. Check selection criteria...'.
                  when 3. write: / 'Unknown Error!'.
                  when 0. perform write_docs.
                  endcase.
                  endloop.
                  Ah y coloca etiquetas cuando pongas código en los post, para facilitar la lectura.
                  -------------------
                  ¿Dudas para descargar manuales? Ver este tema -> Cómo descargar manuales de la sección "Descargas" ?

                  Comentario

                  • Flatron
                    Member
                    • ago
                    • 78

                    #10
                    Gracias DERick.

                    Voy a probar.

                    Comentario

                    • Flatron
                      Member
                      • ago
                      • 78

                      #11
                      Estoy totalmente perdido a la hora de crear la tabla interna.

                      Comentario

                      • DCErick
                        Moderator
                        • mar
                        • 1090

                        #12
                        Originalmente publicado por Flatron
                        Estoy totalmente perdido a la hora de crear la tabla interna.

                        Código:
                        TYPES: BEGIN OF type_pedidos,
                                vbeln  LIKE vbak-vbeln,
                             END OF type_pedidos.
                        
                        DATA: ti_pedidos TYPE TABLE OF  type_pedidos, "Tabla Interna
                                  wa_pedido TYPE type_pedidos.                 "Area de Trabajo.
                        -------------------
                        ¿Dudas para descargar manuales? Ver este tema -> Cómo descargar manuales de la sección "Descargas" ?

                        Comentario

                        • esterg
                          Junior Member
                          • sep
                          • 20

                          #13
                          Un extra

                          Hola,
                          le agregaría :
                          when 1. write: / 'No VBFA found.' , w_comwa-vbeln.
                          when 2. write: / 'No VBUK found. Check selection criteria...' ,w_comwa-vbeln.
                          when 3. write: / 'Unknown Error!', w_comwa-vbeln.

                          para saber en que iteracion del loop estas.

                          Suerte!!
                          Ester.-

                          Comentario

                          • Flatron
                            Member
                            • ago
                            • 78

                            #14
                            Os agradezco a ambos vuestras respuestas y siento el follón que estoy dando.

                            Entonces el programa debería quedar tal que así? Porque así no me carga ni uno solo.

                            tables: vbuk.

                            ** declaración tabla interna
                            TYPES: BEGIN OF type_pedidos,
                            vbeln LIKE vbak-vbeln,
                            END OF type_pedidos.

                            DATA: ti_pedidos TYPE TABLE OF type_pedidos, "Tabla Interna
                            wa_pedido TYPE type_pedidos. "Area de Trabajo.


                            select-options: vbeln for vbuk-vbeln memory id aun obligatory.

                            parameters: posnr like vbap-posnr memory id pid.

                            **
                            *---- Variables --------------------------------------------------------
                            data: w_comwa like vbco6,
                            it_doc like vbfa occurs 0 with header line,
                            it_txt like dd07v occurs 0 with header line,
                            begin of it_type occurs 0,
                            vbtyp like vbuk-vbtyp,
                            text like dd07v-ddtext,
                            end of it_type.
                            *-----------------------------------------------------------------------
                            start-of-selection.
                            loop at ti_pedidos into wa_pedido.
                            w_comwa-mandt = sy-mandt.
                            w_comwa-vbeln = wa_pedido-vbeln.
                            w_comwa-posnr = posnr.

                            call function 'RV_ORDER_FLOW_INFORMATION'
                            exporting
                            comwa = w_comwa
                            tables
                            vbfa_tab = it_doc
                            exceptions
                            no_vbfa = 1
                            no_vbuk_found = 2
                            others = 3.
                            case sy-subrc.
                            when 1. write: / 'No VBFA found.'.
                            when 2. write: / 'No VBUK found. Check selection criteria...'.
                            when 3. write: / 'Unknown Error!'.
                            when 0. perform write_docs.
                            endcase.
                            endloop.

                            *-----------------------------------------------------------------------
                            form write_docs.
                            call function 'GET_DOMAIN_VALUES'
                            exporting
                            domname = 'VBTYP'
                            tables
                            values_tab = it_txt
                            exceptions
                            no_values_found = 1
                            others = 2.
                            case sy-subrc.
                            when 1. write: / 'Warning: No texts found for Sales Docs types!'.
                            when 2. write: / 'Warning: Cannot retrieve SD types descriptions!'.
                            when 0. perform sort_texts.
                            endcase.

                            write: / 'Order Flow Information:'.
                            loop at it_doc.
                            write: / it_doc-stufe,
                            it_doc-vbelv,
                            it_doc-posnv.
                            perform write_type using it_doc-vbtyp_v.
                            write: it_doc-vbeln,
                            it_doc-posnn.
                            perform write_type using it_doc-vbtyp_n.
                            write: it_doc-matnr,
                            it_doc-rfmng unit it_doc-meins,
                            it_doc-meins.
                            endloop.
                            endform.
                            *-----------------------------------------------------------------------
                            form sort_texts.
                            loop at it_txt.
                            it_type-vbtyp = it_txt-domvalue_l.
                            it_type-text = it_txt-ddtext.
                            append it_type.
                            clear it_type.
                            endloop.
                            sort it_type.
                            endform.
                            *-----------------------------------------------------------------------
                            form write_type using value(p_vbtyp) like vbuk-vbtyp.
                            data w_txt(30) type c.
                            read table it_type with key vbtyp = p_vbtyp binary search.
                            case sy-subrc.
                            when 0. w_txt = it_type-text.
                            when others. w_txt = '?'.
                            endcase.
                            write w_txt intensified off.
                            endform.
                            *-----------------------------------------------------------------------

                            Comentario

                            • DCErick
                              Moderator
                              • mar
                              • 1090

                              #15
                              El select-option yo lo declararía así:
                              Código:
                              select-options: p_vbeln for vbuk-vbeln memory id aun obligatory.
                              Y te falta seleccionar los pedidos que están en el rango que indicaste.

                              algo asi:

                              Código:
                              select vbeln into table ti_pedidos
                              where vbeln in p_vbeln.
                              .
                              .
                              ..
                              *Luego el loop at
                              Cuantos tienes en ABAP?
                              -------------------
                              ¿Dudas para descargar manuales? Ver este tema -> Cómo descargar manuales de la sección "Descargas" ?

                              Comentario

                              Trabajando...