Difference between revisions of "SAP PM BAPI HOJARUTA"

From SapWiki
(Created page with "==Leer Hoja de Ruta de Equipo (IA01)== <nowiki>FORM select_data. DATA ld_lines_o TYPE i. DATA ld_lines_m TYPE i. * data para puesto de trabajo (ARBPL) SELECT DISTINCT...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
==Leer Hoja de Ruta de Equipo (IA01)==
+
==Leer Hoja de Ruta de Equipos (IA01)==
 
  <nowiki>FORM select_data.
 
  <nowiki>FORM select_data.
 
   DATA ld_lines_o TYPE i.
 
   DATA ld_lines_o TYPE i.
Line 186: Line 186:
 
     APPEND gs_data_o TO gt_data_o.
 
     APPEND gs_data_o TO gt_data_o.
 
   ENDLOOP.
 
   ENDLOOP.
 +
 +
ENDFORM.                    "select_data</nowiki>
 +
 +
==Leer Hoja de Ruta de Ubicaciones Técnicas (IA11)==
 +
<nowiki>FORM select_data.
 +
  DATA ld_lines_o TYPE i.
 +
  DATA ld_lines_m TYPE i.
 +
 +
* data para puesto de trabajo (ARBPL)
 +
  SELECT DISTINCT objid
 +
                        arbpl
 +
    FROM crhd
 +
    INTO TABLE lt_crhd
 +
  FOR ALL ENTRIES IN gt_plpo
 +
  WHERE objid = gt_plpo-arbid. "#EC CI_NOFIRST
 +
 +
    SELECT  * INTO TABLE gt_tapl from tapl
 +
          WHERE  tplnr  IN s_tplnr
 +
          AND    plnty  =  p_plnty
 +
          AND    iwerk  = p_werks
 +
          AND    loekz  = space.
 +
 +
  CLEAR: gt_plko[],
 +
        gt_plpo[],
 +
        gt_plmk[].
 +
 +
  DESCRIBE TABLE gt_tapl LINES lin.
 +
  LOOP AT gt_tapl INTO gs_tapl.
 +
    succ = 100 / lin * sy-tabix.
 +
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
 +
      EXPORTING
 +
        percentage = succ
 +
        text      = text-001.
 +
 +
    gs_data-tplnr = gs_tapl-tplnr.
 +
    gs_data-werks = gs_tapl-iwerk.
 +
    gs_data-plnal  = gs_tapl-plnal.
 +
 +
    CALL FUNCTION 'CP_EX_PLAN_READ'
 +
      EXPORTING
 +
        plnty_imp    = gs_tapl-plnty
 +
        plnnr_imp    = gs_tapl-plnnr
 +
        plnal_imp    = gs_tapl-plnal
 +
        sttag_imp    = sy-datum
 +
      TABLES
 +
        plko_exp      = gt_plko
 +
        plmz_exp      =    gt_plmz
 +
        plpo_exp      = gt_plpo
 +
        plmk_exp      = gt_plmk
 +
      EXCEPTIONS
 +
        not_found    = 1
 +
        plnal_initial = 2
 +
        OTHERS        = 3
 +
              .
 +
    IF sy-subrc <> 0.
 +
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
 +
*        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 +
    ENDIF.
 +
 +
    DATA ld_cont(2) TYPE n.
 +
 +
    LOOP AT gt_plko INTO gs_plko WHERE  plnty  = gs_tapl-plnty
 +
          AND    plnnr  = gs_tapl-plnnr
 +
          AND    plnal  = gs_tapl-plnal.
 +
 +
      gs_data-sttag  = gs_plko-datuv.
 +
      gs_data-ktext  = gs_plko-ktext.
 +
      gs_data-werks =  gs_plko-werks.
 +
      READ TABLE lt_crhd INTO ls_crhd WITH KEY objid = gs_plko-arbid.
 +
      IF sy-subrc = 0.
 +
        gs_data-arbpl = ls_crhd-arbpl.
 +
      ENDIF.
 +
 +
      gs_data-verwe = gs_plko-verwe.
 +
      gs_data-vagrp = gs_plko-vagrp.
 +
      gs_data-statu = gs_plko-statu.
 +
      gs_data-anlzu = gs_plko-anlzu.
 +
      gs_data-strat = gs_plko-strat.
 +
 +
*      data gt_PLMZ type TABLE OF PLMZPM.
 +
      DATA ls_stpo TYPE stpo.
 +
      DATA gt_stpo TYPE TABLE OF stpo.
 +
      DATA gt_plwp TYPE TABLE OF plwp.
 +
      DATA gs_stpo LIKE LINE OF gt_stpo.
 +
      DATA gs_plwp LIKE LINE OF gt_plwp.
 +
      DATA ld_name LIKE  thead-tdname.
 +
      DATA lt_lines LIKE TABLE OF tline.
 +
      DATA ls_lines LIKE LINE OF lt_lines.
 +
 +
      ld_cont = 0.
 +
      LOOP AT gt_plpo INTO gs_plpo.
 +
        CLEAR: gt_stpo[],
 +
              gt_plwp[].
 +
 +
        ADD 1 TO ld_cont.
 +
 +
        IF ld_cont = 1.
 +
          mc_set_plpo 01.
 +
          gs_data-indet_01 = gs_plpo-indet.
 +
        ELSEIF ld_cont = 2.
 +
          mc_set_plpo 02.
 +
        ELSEIF ld_cont = 3.
 +
          mc_set_plpo 03.
 +
          EXIT.
 +
        ENDIF.
 +
      ENDLOOP.  "operaciones
 +
      MOVE-CORRESPONDING gs_data TO gs_data_o.
 +
      APPEND gs_data_o TO gt_data_o.
 +
 +
    ENDLOOP.  "grupo hoja ruta
 +
 +
  ENDLOOP.  "EAPL</nowiki>
 +
 +
==Leer Hoja de Ruta Instrucciones (IA05)==
 +
<nowiki>FORM select_data.
 +
  DATA ld_lines_o TYPE i.
 +
  DATA ld_lines_m TYPE i.
 +
 +
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_plko_a FROM plko
 +
                                                    WHERE werks = p_werks
 +
                                                    AND plnty  = p_plnty
 +
                                                    AND loekz <> 'X'.
 +
 +
* data para puesto de trabajo (ARBPL)
 +
  SELECT DISTINCT objid
 +
                        arbpl
 +
                        werks
 +
    FROM crhd
 +
    INTO TABLE lt_crhd
 +
  FOR ALL ENTRIES IN gt_plko_a
 +
  WHERE objid = gt_plko_a-arbid.
 +
 +
  CLEAR: gt_plko[],
 +
        gt_plpo[],
 +
        gt_plmk[].
 +
 +
  DESCRIBE TABLE gt_plko_a LINES lin.
 +
 +
  LOOP AT gt_plko_a INTO gs_plko.
 +
    succ = 100 / lin * sy-tabix.
 +
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
 +
      EXPORTING
 +
        percentage = succ
 +
        text      = text-001.
 +
       
 +
    gs_data-werks_h = gs_plko-werks.
 +
    gs_data-plnnr = gs_plko-plnnr.
 +
    gs_data-plnal  = gs_plko-plnal.
 +
 +
    CALL FUNCTION 'CP_EX_PLAN_READ'
 +
      EXPORTING
 +
        plnty_imp    = gs_plko-plnty
 +
        plnnr_imp    = gs_plko-plnnr
 +
        plnal_imp    = gs_plko-plnal
 +
        sttag_imp    = sy-datum
 +
      TABLES
 +
        plko_exp      = gt_plko
 +
        plmz_exp      =    gt_plmz
 +
        plpo_exp      = gt_plpo
 +
        plmk_exp      = gt_plmk
 +
      EXCEPTIONS
 +
        not_found    = 1
 +
        plnal_initial = 2
 +
        OTHERS        = 3
 +
              .
 +
    IF sy-subrc <> 0.
 +
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
 +
*        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 +
    ENDIF.
 +
 +
 +
    LOOP AT gt_plko INTO gs_plko .
 +
      gs_data-ktext  = gs_plko-ktext.
 +
      gs_data-werks_h =  gs_plko-werks.
 +
      READ TABLE lt_crhd INTO ls_crhd WITH KEY objid = gs_plko-arbid.
 +
      IF sy-subrc = 0.
 +
        gs_data-arbpl_h = ls_crhd-arbpl.
 +
        gs_data-werks  = ls_crhd-werks.
 +
      ENDIF.
 +
 +
      gs_data-verwe = gs_plko-verwe.
 +
      gs_data-vagrp = gs_plko-vagrp.
 +
      gs_data-statu = gs_plko-statu.
 +
      gs_data-datuv  = gs_plko-datuv.
 +
 +
    ENDLOOP.  "grupo hoja ruta
 +
 +
  ENDLOOP.  "EAPL</nowiki>
 +
 +
==Leer Hoja de Ruta de Materiales (CA01)==
 +
<nowiki>FORM select_data.
 +
  DATA: BEGIN OF lt_hoja,
 +
        plnnr LIKE mapl-plnnr,
 +
        werks LIKE mapl-werks,
 +
        matnr LIKE mapl-matnr,
 +
    END OF lt_hoja.
 +
 +
  DATA ld_lines_o TYPE i.
 +
  DATA ld_lines_m TYPE i.
 +
 +
* data para puesto de trabajo (ARBPL)
 +
  SELECT DISTINCT objid
 +
                        arbpl
 +
    FROM crhd
 +
    INTO TABLE lt_crhd
 +
  FOR ALL ENTRIES IN gt_plpo
 +
  WHERE objid = gt_plpo-arbid.
 +
 +
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_mapl FROM mapl
 +
                                                    WHERE werks = p_werks
 +
                                                    AND matnr IN s_matnr
 +
                                                    AND plnty  = p_plnty
 +
                                                    AND loekz <> 'X'.
 +
  CLEAR: gt_plko[],
 +
        gt_plpo[],
 +
        gt_plmk[].
 +
  DESCRIBE TABLE gt_mapl LINES lin.
 +
  LOOP AT gt_mapl INTO gs_mapl.
 +
    succ = 100 / lin * sy-tabix.
 +
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
 +
      EXPORTING
 +
        percentage = succ
 +
        text      = text-001.
 +
    CLEAR gs_data.
 +
 +
    gs_data-matnr =  gs_mapl-matnr.
 +
    gs_data-werks =  gs_mapl-werks.
 +
    gs_data-plnnr =  gs_mapl-plnnr.
 +
    gs_data-plnal  = gs_mapl-plnal.
 +
 +
    CALL FUNCTION 'CP_EX_PLAN_READ'
 +
      EXPORTING
 +
        plnty_imp    = gs_mapl-plnty
 +
        plnnr_imp    = gs_mapl-plnnr
 +
        plnal_imp    = gs_mapl-plnal
 +
        sttag_imp    = sy-datum
 +
      TABLES
 +
        plko_exp      = gt_plko
 +
        plpo_exp      = gt_plpo
 +
        plmk_exp      = gt_plmk
 +
      EXCEPTIONS
 +
        not_found    = 1
 +
        plnal_initial = 2
 +
        OTHERS        = 3
 +
              .
 +
    IF sy-subrc <> 0.
 +
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
 +
*        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 +
    ENDIF.
 +
 +
    LOOP AT gt_plko INTO gs_plko WHERE  plnty  = gs_mapl-plnty
 +
          AND    plnnr  = gs_mapl-plnnr
 +
          AND    plnal  = gs_mapl-plnal.
 +
        READ TABLE lt_crhd INTO ls_crhd WITH KEY objid = gs_plpo-arbid.
 +
        IF sy-subrc = 0.
 +
          gs_data-arbpl = ls_crhd-arbpl.
 +
        ENDIF.
 +
 +
        MOVE-CORRESPONDING gs_plpo TO gs_data.
 +
 +
        MOVE-CORRESPONDING gs_data TO gs_data_o.
 +
        PERFORM set_nuevos_valores.
 +
        APPEND gs_data_o TO gt_data_o.
 +
 +
      ENDLOOP. "plpo
 +
      IF sy-subrc <> 0.
 +
        MOVE-CORRESPONDING gs_data TO gs_data_o.
 +
        PERFORM set_nuevos_valores.
 +
        APPEND gs_data_o TO gt_data_o.
 +
 +
      ENDIF.
 +
    ENDLOOP.  "PLKO
 +
  ENDLOOP.  "MAPL
  
 
ENDFORM.                    "select_data</nowiki>
 
ENDFORM.                    "select_data</nowiki>

Latest revision as of 22:46, 6 April 2020

Leer Hoja de Ruta de Equipos (IA01)

FORM select_data.
  DATA ld_lines_o TYPE i.
  DATA ld_lines_m TYPE i.

* data para puesto de trabajo (ARBPL)
  SELECT DISTINCT objid arbpl
     FROM crhd
    INTO TABLE lt_crhd
   FOR ALL ENTRIES IN gt_plpo
  WHERE objid = gt_plpo-arbid.

  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_eapl FROM eapl
                                                    WHERE iwerk = p_werks
                                                    AND equnr IN s_equnr
                                                    AND plnty  = p_plnty
                                                    AND loekz <> 'X'.
  CLEAR: gt_plko[],
         gt_plpo[],
         gt_plmk[].

  DESCRIBE TABLE gt_eapl LINES lin.

  LOOP AT gt_eapl INTO gs_eapl.
    succ = 100 / lin * sy-tabix.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
      EXPORTING
        percentage = succ
        text       = text-001.

    gs_data_h-code = '1'.
    gs_data_h-equnr = gs_eapl-equnr.
    gs_data_h-werks = gs_eapl-iwerk.
    gs_data_h-plnal  = gs_eapl-plnal.

    CALL FUNCTION 'CP_EX_PLAN_READ'
      EXPORTING
        plnty_imp     = gs_eapl-plnty
        plnnr_imp     = gs_eapl-plnnr
        plnal_imp     = gs_eapl-plnal
        sttag_imp     = sy-datum
      TABLES
        plko_exp      = gt_plko
        plmz_exp      =  gt_plmz
        plpo_exp      = gt_plpo
        pltx_exp      = gt_pltxd
        plmk_exp      = gt_plmk
     EXCEPTIONS
       not_found      = 1
       plnal_initial  = 2
      OTHERS         = 3
              .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    LOOP AT gt_plko INTO gs_plko WHERE  plnty  = gs_eapl-plnty
           AND    plnnr  = gs_eapl-plnnr
           AND    plnal  = gs_eapl-plnal.
      gs_data_h-sttag   = gs_plko-datuv.
      gs_data_h-ktext   = gs_plko-ktext.
      gs_data_h-werks =  gs_plko-werks.
      READ TABLE lt_crhd INTO ls_crhd WITH KEY objid = gs_plko-arbid.
      IF sy-subrc = 0.
        gs_data_h-arbpl = ls_crhd-arbpl.
      ENDIF.

      gs_data_h-verwe	= gs_plko-verwe.
      gs_data_h-vagrp = gs_plko-vagrp.
      gs_data_h-statu = gs_plko-statu.
      gs_data_h-anlzu = gs_plko-anlzu.
      gs_data_h-strat = gs_plko-strat.
      gs_data_h-istru = gs_plko-istru.

      PERFORM set_nuevos_valores_h.

      APPEND gs_data_h TO gt_salida.

      DATA ls_stpo TYPE stpo.
      DATA gt_stpo TYPE TABLE OF stpo.
      DATA gt_plwp TYPE TABLE OF plwp.
      DATA gs_stpo LIKE LINE OF gt_stpo.
      DATA gs_plwp LIKE LINE OF gt_plwp.
      DATA ld_equi(8) TYPE n.
      DATA ld_name LIKE  thead-tdname.
      DATA lt_lines LIKE TABLE OF tline.
      DATA ls_lines LIKE LINE OF lt_lines.

      ld_equi = gs_eapl-equnr.

      LOOP AT gt_plpo INTO gs_plpo.
        CLEAR: gt_stpo[],
               gt_plwp[].
        gs_data_d-code = '2'.
 
        MOVE-CORRESPONDING gs_plpo TO gs_data_d.

        READ TABLE lt_crhd INTO ls_crhd WITH KEY objid = gs_plpo-arbid.
        IF sy-subrc = 0.
          gs_data_d-arbpl = ls_crhd-arbpl.
        ENDIF.
        PERFORM set_nuevos_valores_d.
        APPEND gs_data_d TO gt_salida.
      ENDLOOP.  "operaciones
    ENDLOOP.  "grupo hoja ruta

  ENDLOOP.  "EAPL

==Leer Hoja de Ruta Materiales (CA01)==
 <nowiki>FORM select_data.
  DATA: BEGIN OF lt_hoja,
        plnnr LIKE mapl-plnnr,
        werks LIKE mapl-werks,
        matnr LIKE mapl-matnr,
    END OF lt_hoja.

  DATA ld_lines_o TYPE i.
  DATA ld_lines_m TYPE i.

  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_mapl FROM mapl
                                                    WHERE werks = p_werks
                                                    AND matnr IN s_matnr
                                                    AND plnty  = p_plnty
                                                    AND loekz <> 'X'.
  CLEAR: gt_plko[],
         gt_plpo[],
         gt_plmk[].

  DESCRIBE TABLE gt_mapl LINES lin.
  LOOP AT gt_mapl INTO gs_mapl.
    succ = 100 / lin * sy-tabix.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
      EXPORTING
        percentage = succ
        text       = text-001.
    CLEAR gs_data.

    gs_data-datuv = gs_mapl-datuv.
    gs_data-material = gs_mapl-matnr.
    gs_data-plant = gs_mapl-werks.
    gs_data-task_list_group = gs_mapl-plnnr.
    gs_data-group_counter  = gs_mapl-plnal.

    CALL FUNCTION 'CP_EX_PLAN_READ'
      EXPORTING
        plnty_imp     = gs_mapl-plnty
        plnnr_imp     = gs_mapl-plnnr
        plnal_imp     = gs_mapl-plnal
        sttag_imp     = sy-datum
      TABLES
        plko_exp      = gt_plko                            =
        plpo_exp      = gt_plpo
        plmk_exp      = gt_plmk
      EXCEPTIONS
        not_found     = 1
        plnal_initial = 2
        OTHERS        = 3
              .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    LOOP AT gt_plko INTO gs_plko WHERE  plnty  = gs_mapl-plnty
           AND    plnnr  = gs_mapl-plnnr
           AND    plnal  = gs_mapl-plnal.

      gs_data-ident_key                    = gs_plko-slwbez.
      gs_data-insppoint_partiallot_assgnmt =  gs_plko-ppkztlzu.
      gs_data-dyn_modif_level	= gs_plko-qdynhead.
      gs_data-dyn_modif_rule  = gs_plko-qdynregel.
      gs_data-quantonce       = gs_plko-ppkztlzu.
      gs_data-task_measure_unit = gs_plko-plnme.
    ENDLOOP.  "PLKO
  ENDLOOP.   "MAPL

  LOOP AT gt_data INTO gs_data.
    MOVE gs_data-task_list_group  TO 	gs_data_o-group.
    MOVE gs_data-group_counter  TO 	gs_data_o-grcnt.
    MOVE gs_data-datuv  TO 	gs_data_o-date.
    MOVE gs_data-ident_key  TO 	gs_data_o-insp_point.
    MOVE gs_data-quantonce  TO 	gs_data_o-part_lot.
    MOVE gs_data-dyn_modif_level  TO 	gs_data_o-dm_level.
    MOVE gs_data-dyn_modif_rule  TO   gs_data_o-dm_rule.
    APPEND gs_data_o TO gt_data_o.
  ENDLOOP.

ENDFORM.                    "select_data

Leer Hoja de Ruta de Ubicaciones Técnicas (IA11)

FORM select_data.
  DATA ld_lines_o TYPE i.
  DATA ld_lines_m TYPE i.

* data para puesto de trabajo (ARBPL)
  SELECT DISTINCT objid
                        arbpl
     FROM crhd
    INTO TABLE lt_crhd
   FOR ALL ENTRIES IN gt_plpo
  WHERE objid = gt_plpo-arbid. "#EC CI_NOFIRST

    SELECT  * INTO TABLE gt_tapl from tapl
           WHERE  tplnr  IN s_tplnr
           AND    plnty  =  p_plnty
           AND    iwerk  = p_werks
           AND    loekz  = space.

  CLEAR: gt_plko[],
         gt_plpo[],
         gt_plmk[].

  DESCRIBE TABLE gt_tapl LINES lin.
  LOOP AT gt_tapl INTO gs_tapl.
    succ = 100 / lin * sy-tabix.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
      EXPORTING
        percentage = succ
        text       = text-001.

    gs_data-tplnr = gs_tapl-tplnr.
    gs_data-werks = gs_tapl-iwerk.
    gs_data-plnal  = gs_tapl-plnal.

    CALL FUNCTION 'CP_EX_PLAN_READ'
      EXPORTING
        plnty_imp     = gs_tapl-plnty
        plnnr_imp     = gs_tapl-plnnr
        plnal_imp     = gs_tapl-plnal
        sttag_imp     = sy-datum
      TABLES
        plko_exp      = gt_plko
        plmz_exp      =    gt_plmz
        plpo_exp      = gt_plpo
        plmk_exp      = gt_plmk
      EXCEPTIONS
        not_found     = 1
        plnal_initial = 2
        OTHERS        = 3
              .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    DATA ld_cont(2) TYPE n.

    LOOP AT gt_plko INTO gs_plko WHERE  plnty  = gs_tapl-plnty
           AND    plnnr  = gs_tapl-plnnr
           AND    plnal  = gs_tapl-plnal.

      gs_data-sttag   = gs_plko-datuv.
      gs_data-ktext   = gs_plko-ktext.
      gs_data-werks =  gs_plko-werks.
      READ TABLE lt_crhd INTO ls_crhd WITH KEY objid = gs_plko-arbid.
      IF sy-subrc = 0.
        gs_data-arbpl = ls_crhd-arbpl.
      ENDIF.

      gs_data-verwe	= gs_plko-verwe.
      gs_data-vagrp = gs_plko-vagrp.
      gs_data-statu = gs_plko-statu.
      gs_data-anlzu = gs_plko-anlzu.
      gs_data-strat = gs_plko-strat.

*      data gt_PLMZ type TABLE OF PLMZPM.
      DATA ls_stpo TYPE stpo.
      DATA gt_stpo TYPE TABLE OF stpo.
      DATA gt_plwp TYPE TABLE OF plwp.
      DATA gs_stpo LIKE LINE OF gt_stpo.
      DATA gs_plwp LIKE LINE OF gt_plwp.
      DATA ld_name LIKE  thead-tdname.
      DATA lt_lines LIKE TABLE OF tline.
      DATA ls_lines LIKE LINE OF lt_lines.

      ld_cont = 0.
      LOOP AT gt_plpo INTO gs_plpo.
        CLEAR: gt_stpo[],
               gt_plwp[].

        ADD 1 TO ld_cont.

        IF ld_cont = 1.
          mc_set_plpo 01.
          gs_data-indet_01 = gs_plpo-indet.
        ELSEIF ld_cont = 2.
          mc_set_plpo 02.
        ELSEIF ld_cont = 3.
          mc_set_plpo 03.
          EXIT.
        ENDIF.
      ENDLOOP.  "operaciones
      MOVE-CORRESPONDING gs_data TO gs_data_o.
      APPEND gs_data_o TO gt_data_o.

    ENDLOOP.  "grupo hoja ruta

  ENDLOOP.  "EAPL

Leer Hoja de Ruta Instrucciones (IA05)

FORM select_data.
  DATA ld_lines_o TYPE i.
  DATA ld_lines_m TYPE i.

  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_plko_a FROM plko
                                                    WHERE werks = p_werks
                                                    AND plnty  = p_plnty
                                                    AND loekz <> 'X'.

* data para puesto de trabajo (ARBPL)
  SELECT DISTINCT objid
                        arbpl
                        werks
     FROM crhd
    INTO TABLE lt_crhd
   FOR ALL ENTRIES IN gt_plko_a
  WHERE objid = gt_plko_a-arbid.

  CLEAR: gt_plko[],
         gt_plpo[],
         gt_plmk[].

  DESCRIBE TABLE gt_plko_a LINES lin.

  LOOP AT gt_plko_a INTO gs_plko.
    succ = 100 / lin * sy-tabix.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
      EXPORTING
        percentage = succ
        text       = text-001.
        
    gs_data-werks_h = gs_plko-werks.
    gs_data-plnnr = gs_plko-plnnr.
    gs_data-plnal  = gs_plko-plnal.

    CALL FUNCTION 'CP_EX_PLAN_READ'
      EXPORTING
        plnty_imp     = gs_plko-plnty
        plnnr_imp     = gs_plko-plnnr
        plnal_imp     = gs_plko-plnal
        sttag_imp     = sy-datum
      TABLES
        plko_exp      = gt_plko
        plmz_exp      =    gt_plmz
        plpo_exp      = gt_plpo
        plmk_exp      = gt_plmk
      EXCEPTIONS
        not_found     = 1
        plnal_initial = 2
        OTHERS        = 3
              .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.


    LOOP AT gt_plko INTO gs_plko .
      gs_data-ktext   = gs_plko-ktext.
      gs_data-werks_h =  gs_plko-werks.
      READ TABLE lt_crhd INTO ls_crhd WITH KEY objid = gs_plko-arbid.
      IF sy-subrc = 0.
        gs_data-arbpl_h = ls_crhd-arbpl.
        gs_data-werks   = ls_crhd-werks.
      ENDIF.

      gs_data-verwe	= gs_plko-verwe.
      gs_data-vagrp = gs_plko-vagrp.
      gs_data-statu = gs_plko-statu.
      gs_data-datuv  = gs_plko-datuv.

    ENDLOOP.  "grupo hoja ruta

  ENDLOOP.  "EAPL

Leer Hoja de Ruta de Materiales (CA01)

FORM select_data.
  DATA: BEGIN OF lt_hoja,
        plnnr LIKE mapl-plnnr,
        werks LIKE mapl-werks,
        matnr LIKE mapl-matnr,
    END OF lt_hoja.

  DATA ld_lines_o TYPE i.
  DATA ld_lines_m TYPE i.

* data para puesto de trabajo (ARBPL)
  SELECT DISTINCT objid
                        arbpl
     FROM crhd
    INTO TABLE lt_crhd
   FOR ALL ENTRIES IN gt_plpo
  WHERE objid = gt_plpo-arbid.

  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_mapl FROM mapl
                                                    WHERE werks = p_werks
                                                    AND matnr IN s_matnr
                                                    AND plnty  = p_plnty
                                                    AND loekz <> 'X'.
  CLEAR: gt_plko[],
         gt_plpo[],
         gt_plmk[].
  DESCRIBE TABLE gt_mapl LINES lin.
  LOOP AT gt_mapl INTO gs_mapl.
    succ = 100 / lin * sy-tabix.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
      EXPORTING
        percentage = succ
        text       = text-001.
    CLEAR gs_data.

    gs_data-matnr =  gs_mapl-matnr.
    gs_data-werks =  gs_mapl-werks.
    gs_data-plnnr =  gs_mapl-plnnr.
    gs_data-plnal  = gs_mapl-plnal.

    CALL FUNCTION 'CP_EX_PLAN_READ'
      EXPORTING
        plnty_imp     = gs_mapl-plnty
        plnnr_imp     = gs_mapl-plnnr
        plnal_imp     = gs_mapl-plnal
        sttag_imp     = sy-datum
      TABLES
        plko_exp      = gt_plko
        plpo_exp      = gt_plpo
        plmk_exp      = gt_plmk
      EXCEPTIONS
        not_found     = 1
        plnal_initial = 2
        OTHERS        = 3
              .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    LOOP AT gt_plko INTO gs_plko WHERE  plnty  = gs_mapl-plnty
           AND    plnnr  = gs_mapl-plnnr
           AND    plnal  = gs_mapl-plnal.
        READ TABLE lt_crhd INTO ls_crhd WITH KEY objid = gs_plpo-arbid.
        IF sy-subrc = 0.
          gs_data-arbpl = ls_crhd-arbpl.
        ENDIF.

        MOVE-CORRESPONDING gs_plpo TO gs_data.

        MOVE-CORRESPONDING gs_data TO gs_data_o.
        PERFORM set_nuevos_valores.
        APPEND gs_data_o TO gt_data_o.

      ENDLOOP. "plpo
      IF sy-subrc <> 0.
        MOVE-CORRESPONDING gs_data TO gs_data_o.
        PERFORM set_nuevos_valores.
        APPEND gs_data_o TO gt_data_o.

      ENDIF.
    ENDLOOP.  "PLKO
  ENDLOOP.   "MAPL

ENDFORM.                    "select_data