SAP SD Transporte

From SapWiki

Códigos Varios Transporte

Ejemplo 01

FORM get_data.
   SELECT * INTO TABLE gt_tvko FROM tvko.
 
   SELECT i~fkart
          p~bukrs
          p~tdlnr
          p~exti1
          p~fknum
          p~fkpos
          p~rebel
          p~waers INTO CORRESPONDING FIELDS OF TABLE gt_header FROM vfkk AS i
                                         INNER JOIN vfkp AS p
                                                 ON i~fknum = p~fknum
                                             WHERE i~erdat IN s_erdat
                                                AND p~exti1 IN s_exti1
                                                AND p~exti1 <> space
                                                AND p~tdlnr = p_tdlnr.
 
   SELECT SINGLE name1 INTO g_name1 FROM lfa1 WHERE lifnr = p_tdlnr.
 
   LOOP AT gt_header INTO wa_data.
     wa_data-name1 = g_name1.
 
     SELECT SINGLE tknum shtyp route signi vsart bfart vsbed sdabw
                          INTO wa_vttk FROM vttk  WHERE tknum = wa_data-rebel.
     IF sy-subrc = 0.
       wa_data-shtyp = wa_vttk-shtyp.
       wa_data-route = wa_vttk-route.
       wa_data-signi = wa_vttk-signi.
       wa_data-vsart = wa_vttk-vsart.
       wa_data-bfart = wa_vttk-bfart.
 
       l_domv = wa_data-bfart.
 
       CALL FUNCTION 'DOMAIN_VALUE_GET'
         EXPORTING
           i_domname  = 'BFART'
           i_domvalue = l_domv
         IMPORTING
           e_ddtext   = l_ddt
         EXCEPTIONS
           not_exist  = 1
           OTHERS     = 2.
       MOVE l_ddt TO wa_data-stext.
       wa_data-vsbed = wa_vttk-vsbed.
       wa_data-sdabw = wa_vttk-sdabw.
 
       SELECT SINGLE bezei INTO wa_data-bezei FROM  t173t
              WHERE  spras  = sy-langu
              AND    vsart  = wa_data-vsart.
 
       SELECT SINGLE vtext INTO wa_data-vtext FROM  tvsbt
              WHERE  spras  = sy-langu
              AND    vsbed  = wa_data-vsbed.
 
       SELECT SINGLE bezei INTO wa_data-bezei2  FROM  tvsakt
              WHERE  spras  = sy-langu
              AND    sdabw  = wa_data-sdabw.
 
       SELECT * INTO TABLE gt_vttp FROM vttp WHERE tknum = wa_vttk-tknum.
 
       IF gt_vttp[] IS NOT INITIAL.
         SELECT i~vkorg
                p~vbeln
                p~posnr
                p~matnr INTO TABLE gt_lips FROM likp AS i
                                     INNER JOIN lips AS p
                                             ON i~vbeln = p~vbeln FOR ALL ENTRIES IN gt_vttp
                                          WHERE i~vbeln = gt_vttp-vbeln.
 
         SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vfkn FROM vfkn WHERE fknum = wa_data-fknum
                                                                         AND fkpos = wa_data-fkpos.
 
         LOOP AT gt_lips INTO wa_lips.
           READ TABLE gt_tvko WITH TABLE KEY vkorg = wa_lips-vkorg.
           wa_data-bukrs = gt_tvko-bukrs.
 
           wa_data-vbeln = wa_lips-vbeln.
           wa_data-posnr = wa_lips-posnr.
           wa_data-matnr = wa_lips-matnr.
           wa_data-netwr_pro = p_monto / 100.
 
           READ TABLE gt_vfkn INTO wa_vfkn WITH KEY retyp = 'J'   "entrega
                                          fknum = wa_data-fknum
                                          fkpos = wa_data-fkpos
                                          rebel = wa_lips-vbeln
                                          repos = wa_lips-posnr.
           IF sy-subrc = 0.
             wa_data-netwr = wa_vfkn-netwr.
           ENDIF.
         ENDLOOP.
       ENDIF.
     ENDIF.
   ENDLOOP.
 
 ENDFORM.

Obtener icono de Camioncito en reportes ALV

 form get_vsart_text USING p_vsart CHANGING p_txt.
  data l_bezei type T173T-bezei.
  data  l_icon_shipping_type(100) TYPE c.

  if p_VSART is not INITIAL.
    SELECT   single bezei into l_bezei FROM  T173T
           WHERE  SPRAS  = sy-langu
           AND    VSART  = p_VSART.
    if sy-subrc = 0.
      move l_BEZEI to p_TXT.

      clear l_ICON_SHIPPING_TYPE.
      CALL FUNCTION 'ST_STAGE_ICON_SHIPPING_TYPE'
        EXPORTING
          I_SHIPPING_TYPE = p_VSART
        CHANGING
          C_ICON          = l_ICON_SHIPPING_TYPE
        EXCEPTIONS
          OTHERS          = 0.

 * add the icons for the shipping types
      IF not l_icon_shipping_type is initial.
        CONCATENATE l_icon_shipping_type p_txt
                    INTO p_txt SEPARATED BY space.
      ENDIF.
    endif.
  else.
    clear p_txt.
  endif.

 ENDFORM.