<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Insert new data with Batch Input in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-new-data-with-batch-input/m-p/12424555#M1997469</link>
    <description>&lt;P&gt;Doh! I did not know if there is an answer the OP cannot edit the question. Makes sense. My fault, then.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Aug 2021 06:12:23 GMT</pubDate>
    <dc:creator>VXLozano</dc:creator>
    <dc:date>2021-08-19T06:12:23Z</dc:date>
    <item>
      <title>Insert new data with Batch Input</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-new-data-with-batch-input/m-p/12424552#M1997466</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;
  &lt;P&gt;I have a problem with a program that uses a Batch Input.&lt;/P&gt;
  &lt;P&gt;When the IDOBJ exist in table, it makes the correct update, but when it doesn't exists it doesn't make the insert. I copy the code:&lt;/P&gt;
  &lt;P&gt;FORM realizar_carga USING pt_alv TYPE tt_alv.&lt;BR /&gt;&lt;BR /&gt;DATA: ls_cab LIKE LINE OF pt_alv.&lt;BR /&gt;data: lv_op(4) type c.&lt;BR /&gt;&lt;BR /&gt;LOOP AT pt_alv[] INTO ls_cab.&lt;BR /&gt;*lectura cabecera documento&lt;BR /&gt;&lt;BR /&gt; REFRESH gt_bdcdata.&lt;BR /&gt;SELECT SINGLE * FROM HRP1000 WHERE&lt;BR /&gt; plvar eq '01' and&lt;BR /&gt; otype eq 'P0' and&lt;BR /&gt; OBJID eq ls_cab-id.&lt;BR /&gt; if sy-subrc eq 0.&lt;BR /&gt; lv_op = '=UPD'.&lt;BR /&gt; ELSE.&lt;BR /&gt; lv_op = '=INS'.&lt;BR /&gt; endif.&lt;BR /&gt;* --------------------------------------------------------------------*&lt;BR /&gt; PERFORM f_bdc_dynpro USING 'SAPMH5A0' '5000'.&lt;BR /&gt; PERFORM f_bdc_field USING 'BDC_CURSOR' 'PM0D1-SEARK' space.&lt;BR /&gt; PERFORM f_bdc_field USING 'BDC_OKCODE' '/00' space.&lt;BR /&gt; PERFORM f_bdc_field USING 'PPHDR-PLVAR' '01' space.&lt;BR /&gt; PERFORM f_bdc_field USING 'PPHDR-OTYPE' 'P0' space.&lt;BR /&gt; PERFORM f_bdc_field USING 'PM0D1-SEARK' ls_cab-id space.&lt;BR /&gt; PERFORM f_bdc_field USING 'BDC_SUBSCR' 'SAPMH5A0' '5005SUB1'.&lt;BR /&gt;* --------------------------------------------------------------------*&lt;BR /&gt; PERFORM f_bdc_dynpro USING 'SAPMH5A0' '5000'.&lt;BR /&gt; PERFORM f_bdc_field USING 'BDC_OKCODE' '=AEND' space.&lt;BR /&gt; PERFORM f_bdc_field USING 'PPHDR-PLVAR' '01' space.&lt;BR /&gt; PERFORM f_bdc_field USING 'PPHDR-OTYPE' 'P0' space.&lt;BR /&gt; PERFORM f_bdc_field USING 'PM0D1-SEARK' ls_cab-id space.&lt;BR /&gt; PERFORM f_bdc_field USING 'BDC_SUBSCR' 'SAPMH5A0' '5005SUB1'.&lt;BR /&gt; PERFORM f_bdc_field USING 'BDC_CURSOR' 'TT_T777T-ITEXT(01)' space.&lt;BR /&gt; PERFORM f_bdc_field USING 'MARKFELD(01)' 'X' space.&lt;BR /&gt;* --------------------------------------------------------------------*&lt;BR /&gt; PERFORM f_bdc_dynpro USING 'MP100000' '2000'.&lt;BR /&gt; PERFORM f_bdc_field USING 'BDC_CURSOR' 'P1000-STEXT' space.&lt;BR /&gt;* PERFORM f_bdc_field USING 'BDC_OKCODE' '=UPD' space.&lt;BR /&gt; PERFORM f_bdc_field USING 'BDC_OKCODE' lv_op space.&lt;BR /&gt; PERFORM f_bdc_field USING 'P1000-SHORT' ls_cab-desc_breve space.&lt;BR /&gt; PERFORM f_bdc_field USING 'P1000-STEXT' ls_cab-desc space.&lt;BR /&gt; PERFORM f_bdc_field USING 'P1000-LANGU' ls_cab-idioma space.&lt;BR /&gt;&lt;BR /&gt; DATA: ctumode LIKE ctu_params-dismode VALUE 'N'.&lt;BR /&gt; "A: show all dynpros&lt;BR /&gt; "E: show dynpro on error only&lt;BR /&gt; "N: do not display dynpro&lt;BR /&gt;&lt;BR /&gt; DATA: cupdate LIKE ctu_params-updmode VALUE 'A'.&lt;BR /&gt; "S: synchronously&lt;BR /&gt; "A: asynchronously&lt;BR /&gt; "L: local&lt;BR /&gt; DATA: messtab TYPE STANDARD TABLE OF bdcmsgcoll,&lt;BR /&gt; ls_messtab TYPE bdcmsgcoll.&lt;BR /&gt; CLEAR messtab.&lt;BR /&gt; CALL TRANSACTION 'PP01' USING gt_bdcdata&lt;BR /&gt; MODE ctumode&lt;BR /&gt;* UPDATE cupdate&lt;BR /&gt; MESSAGES INTO messtab.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; READ TABLE messtab INTO ls_messtab WITH KEY msgtyp = 'E'.&lt;BR /&gt; IF sy-subrc NE 0.&lt;BR /&gt;&lt;BR /&gt;* select single * from HRP1000&lt;BR /&gt;* where OTYPE eq 'P0'&lt;BR /&gt;* AND OBJID EQ gt_bdcdata-&lt;BR /&gt; gs_alv-icon = icon_green_light .&lt;BR /&gt;&lt;BR /&gt; ELSE.&lt;BR /&gt; gs_alv-icon = icon_red_light .&lt;BR /&gt;&lt;BR /&gt; ENDIF.&lt;BR /&gt;&lt;BR /&gt; MODIFY gt_alv FROM gs_alv TRANSPORTING icon.&lt;BR /&gt;ENDLOOP.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 09:55:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-new-data-with-batch-input/m-p/12424552#M1997466</guid>
      <dc:creator>former_member628493</dc:creator>
      <dc:date>2021-08-18T09:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Insert new data with Batch Input</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-new-data-with-batch-input/m-p/12424553#M1997467</link>
      <description>&lt;P&gt;(please, edit the question by selecting all the code and pressing the CODE button... it will make your post much more readable)&lt;/P&gt;&lt;P&gt;First of all: try to find another way to do that work. I'm not sure which SAP object the PP01 transaction works with, but if you find a BAPI or a class that does that same work, it will make your life easier and the program much more resistant to SAP updates.&lt;/P&gt;&lt;P&gt;A Batch Input is nothing else than a recorded process. It behaves just like the system will do if you do the whole process manually, so if your data raises a message or a pop-up asking for information or any other unexpected thing, the whole process will stop working.&lt;/P&gt;&lt;P&gt;Put a breakpoint inside the LOOP, and when it reaches the idobj you know it "crashes", keep going line by line until you have your CTUMODE as "N"... then change its value to "E" (or even to "A").&lt;/P&gt;&lt;P&gt;Then keep the execution (F8) and you will see every step of the recording.&lt;/P&gt;&lt;P&gt;Once you know what's happening, you'll need to adapt the "recording" to take care of the special case (ie adding another screen with info).&lt;/P&gt;&lt;P&gt;An easier and maybe cleaner way to fix this may be to create a new recording using information of the new case and use one or the other depending on the info of the loop's row.&lt;/P&gt;&lt;P&gt;But I strongly advice to seek for an alternate process before. To use a Batch Input is like to walk into a lightstorm carrying a copper stick raised over your head.&lt;/P&gt;&lt;P&gt;------------------------ spanish translation&lt;/P&gt;&lt;P&gt;(edita el mensaje seleccionando el código y dándole al botón CODE... será mucho más agradable y fácil de leer)&lt;/P&gt;&lt;P&gt;Primero: intenta encontrar otra forma de hacer lo que intentas. No sé qué hace la PP01, pero si encuentras una BAPI o una clase que haga lo mismo que la transacción, tu vida será más fácil y el programa más resistente a actualizaciones de SAP.&lt;/P&gt;&lt;P&gt;Un BI es una grabación de un proceso. Se comporta exactamente como lo haría el sistema si le fueras metiendo la info a mano, así que si tus datos hacen que SAP quiera sacar un mensaje o un popup pidiendo información adicional, o cualquier otra cosa que no está en la grabación, el proceso se va al carajo.&lt;/P&gt;&lt;P&gt;Pon un break-point en el LOOP, y cuando estés en el registro que no funciona, debuga hasta que CTUMODE tenga el valor "N" y cámbialo por "E" (o mejor por "A").&lt;/P&gt;&lt;P&gt;Dale a seguir (F8) y verás lo que le pasa a la grabación.&lt;/P&gt;&lt;P&gt;Cuando sepas lo que pasa, tendrás que adaptar la grabación para tener en cuenta el caso especial (añadiendo la información de la pantalla adicional, o lo que sea).&lt;/P&gt;&lt;P&gt;Una forma más sencilla y quizá más limpia sería crear una grabación nueva con los datos que te generan el error, y ejecutar una grabación o la otra en función de la información de la línea del LOOP.&lt;/P&gt;&lt;P&gt;Pero sigo recomendándote buscar una vía alternativa. Usar un batch input es como pasear bajo los rayos llevando un poste de cobre sobre la cabeza.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 10:52:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-new-data-with-batch-input/m-p/12424553#M1997467</guid>
      <dc:creator>VXLozano</dc:creator>
      <dc:date>2021-08-18T10:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Insert new data with Batch Input</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-new-data-with-batch-input/m-p/12424554#M1997468</link>
      <description>&lt;P&gt;You cannot edit your question anymore now that there is an answer, but next time please select your code and press the [CODE] button to format it correctly. Thank you. Like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FORM realizar_carga USING pt_alv TYPE tt_alv.

  DATA: ls_cab LIKE LINE OF pt_alv.
  data: lv_op(4) type c.

  LOOP AT pt_alv[] INTO ls_cab.
* lectura cabecera documento

    REFRESH gt_bdcdata.
    SELECT SINGLE * FROM HRP1000 WHERE
        plvar eq '01' and
        otype eq 'P0' and
        OBJID eq ls_cab-id.
    if sy-subrc eq 0.
      lv_op = '=UPD'.
    ELSE.
      lv_op = '=INS'.
    endif.
* --------------------------------------------------------------------*
    PERFORM f_bdc_dynpro USING 'SAPMH5A0' '5000'.
    PERFORM f_bdc_field USING 'BDC_CURSOR' 'PM0D1-SEARK' space.
    PERFORM f_bdc_field USING 'BDC_OKCODE' '/00' space.
    PERFORM f_bdc_field USING 'PPHDR-PLVAR' '01' space.
    PERFORM f_bdc_field USING 'PPHDR-OTYPE' 'P0' space.
    PERFORM f_bdc_field USING 'PM0D1-SEARK' ls_cab-id space.
    PERFORM f_bdc_field USING 'BDC_SUBSCR' 'SAPMH5A0' '5005SUB1'.
* --------------------------------------------------------------------*
    PERFORM f_bdc_dynpro USING 'SAPMH5A0' '5000'.
    PERFORM f_bdc_field USING 'BDC_OKCODE' '=AEND' space.
    PERFORM f_bdc_field USING 'PPHDR-PLVAR' '01' space.
    PERFORM f_bdc_field USING 'PPHDR-OTYPE' 'P0' space.
    PERFORM f_bdc_field USING 'PM0D1-SEARK' ls_cab-id space.
    PERFORM f_bdc_field USING 'BDC_SUBSCR' 'SAPMH5A0' '5005SUB1'.
    PERFORM f_bdc_field USING 'BDC_CURSOR' 'TT_T777T-ITEXT(01)' space.
    PERFORM f_bdc_field USING 'MARKFELD(01)' 'X' space.
* --------------------------------------------------------------------*
    PERFORM f_bdc_dynpro USING 'MP100000' '2000'.
    PERFORM f_bdc_field USING 'BDC_CURSOR' 'P1000-STEXT' space.
*    PERFORM f_bdc_field USING 'BDC_OKCODE' '=UPD' space.
    PERFORM f_bdc_field USING 'BDC_OKCODE' lv_op space.
    PERFORM f_bdc_field USING 'P1000-SHORT' ls_cab-desc_breve space.
    PERFORM f_bdc_field USING 'P1000-STEXT' ls_cab-desc space.
    PERFORM f_bdc_field USING 'P1000-LANGU' ls_cab-idioma space.


    DATA: ctumode LIKE ctu_params-dismode VALUE 'N'.
    "A: show all dynpros
    "E: show dynpro on error only
    "N: do not display dynpro


    DATA: cupdate LIKE ctu_params-updmode VALUE 'A'.
    "S: synchronously
    "A: asynchronously
    "L: local
    DATA: messtab TYPE STANDARD TABLE OF bdcmsgcoll,
          ls_messtab TYPE bdcmsgcoll.
    CLEAR messtab.
    CALL TRANSACTION 'PP01' USING gt_bdcdata
        MODE ctumode
*        UPDATE cupdate
        MESSAGES INTO messtab.

    READ TABLE messtab INTO ls_messtab WITH KEY msgtyp = 'E'.
    IF sy-subrc NE 0.

*    select single * from HRP1000
*         where OTYPE eq 'P0'
*           AND OBJID EQ gt_bdcdata-
      gs_alv-icon = icon_green_light .

    ELSE.
      gs_alv-icon = icon_red_light .

    ENDIF.

  MODIFY gt_alv FROM gs_alv TRANSPORTING icon.
ENDLOOP.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Aug 2021 12:06:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-new-data-with-batch-input/m-p/12424554#M1997468</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-08-18T12:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Insert new data with Batch Input</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-new-data-with-batch-input/m-p/12424555#M1997469</link>
      <description>&lt;P&gt;Doh! I did not know if there is an answer the OP cannot edit the question. Makes sense. My fault, then.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 06:12:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-new-data-with-batch-input/m-p/12424555#M1997469</guid>
      <dc:creator>VXLozano</dc:creator>
      <dc:date>2021-08-19T06:12:23Z</dc:date>
    </item>
  </channel>
</rss>

