Friday, November 8, 2019

Delivery VL01N and VL02N transaction Save and Post Goods Issue (PGI) Button Validation

Delivery VL01N and VL02N transaction Save and Post Goods Issue (PGI) Button Validation


On Save button validation spot

Tcode                           : SE19
BADI Name                 : LE_SHP_DELIVERY_PROC
Implementation Name : ZDELIVERY_SAVE   "Any name you can give
Enhancement Name     : ZDELIVERY_SAVE_VALIDATION  "Any name you can give
Under Method              : SAVE_DOCUMENT_PREPARE



we wrote our code  in method   SAVE_AND_PUBLISH_BEFORE_OUTPUT.to send SMS to user with Delivery Details and weight  and etc.
 

  method IF_EX_LE_SHP_DELIVERY_PROC~SAVE_AND_PUBLISH_BEFORE_OUTPUT.
    break sap_abap.
    BREAK sap_abap2.
    IF SY-TCODE 'VL01N' AND SY-UCOMM 'SICH_T'.
    DATAL_MSG TYPE STRING,
      L_NAME1 TYPE NAME1_GP,
      L_NAME_L TYPE NAME1_GP,
      L_BRGEW(16TYPE C,
      L_LFIMG(16TYPE C,
      L_WT(16)  TYPE C,
      L_QTY(16)  TYPE C,
      L_DATE(10TYPE C,
      L_KBETR TYPE KBETR,
      L_KNUMV TYPE KNUMV,
      L_RATE(13TYPE C,
      l_tel  TYPE telf1,
      l_tel_B TYPE telf1.


    READ TABLE IT_XLIKP INTO DATA(WA_LIKPINDEX 1.
    READ TABLE IT_XLIPS INTO DATA(WA_LIPSINDEX 1.

    SELECT SINGLE KNUMV FROM VBAK INTO L_KNUMV WHERE VBELN WA_LIPS-VGBEL.
    SELECT SINGLE KBETR FROM KONV INTO L_KBETR WHERE KNUMV L_KNUMV AND KSCHL 'ZNET'.
    IF SY-SUBRC 0.
    L_RATE L_KBETR.
    ELSE.
    SELECT SINGLE KBETR FROM KONV INTO L_KBETR WHERE KNUMV L_KNUMV AND KSCHL 'ZNE1'.
    L_RATE L_KBETR.
    ENDIF.
    CONDENSE L_RATE.

    READ TABLE IT_XVBPA INTO DATA(WA_VBPAWITH KEY PARVW 'WE'.
    IF SY-SUBRC 0.
     SELECT SINGLE NAME1 FROM KNA1 INTO L_NAME1 WHERE KUNNR WA_VBPA-KUNNR.
     SELECT SINGLE telf1 FROM KNA1 INTO l_tel WHERE KUNNR WA_VBPA-KUNNR.
    ENDIF.
    SELECT FROM vbpa INTO TABLE @DATA(I_VBPAWHERE VBELN @WA_LIPS-VGBEL.
    READ TABLE I_VBPA INTO DATA(WA_VBPA1WITH KEY PARVW 'LF'.
    IF SY-SUBRC 0.
      SELECT SINGLE NAME1 FROM LFA1 INTO L_NAME_L WHERE LIFNR WA_VBPA1-LIFNR.
      SELECT SINGLE telf1 FROM LFA1 INTO l_tel_B WHERE LIFNR WA_VBPA1-LIFNR.
    ENDIF.
    L_LFIMG WA_LIPS-LFIMG.
    L_BRGEW WA_LIPS-BRGEW.
    CONDENSEL_LFIMG,L_BRGEW.
    CONCATENATE WA_LIKP-LFDAT+6(2'-' WA_LIKP-LFDAT+4(2'-' WA_LIKP-LFDAT+0(4INTO L_DATE.
    concatenate 'A Do_No:' WA_LIKP-VBELN  ', Sale_Order No-:'  WA_LIPS-VGBEL 'Is Generated for Item:'
    WA_LIPS-ARKTX  'Party:' L_NAME1 'Create On Date:' L_DATE 'Quantity:' L_LFIMG  'Weight:' L_BRGEW 'RATE:' L_RATE
    'Broker:' L_NAME_L INTO L_MSG SEPARATED BY SPACE.

    IF L_TEL_B IS NOT INITIAL.
     CALL FUNCTION 'ZSEND_SMS'
                    EXPORTING
                      pmob_no       l_tel_b+0(10)
                      pmesg         l_msg.
    ELSE.
     CALL FUNCTION 'ZSEND_SMS'
                   EXPORTING
                      pmob_no       l_tel+0(10)
                      pmesg         l_msg.
    ENDIF.

CLEARL_NAME_L,L_NAME1,L_BRGEW,l_tel.

    ENDIF.
  endmethod.