ZSDRSP001:deliver information for shipment plan and daily shipping report 2

  describe table itab3 lines lv_total_line.
  loop at itab3.
    lv_line =  sy-tabix  / lv_total_line * 100.
    call function 'SAPGUI_PROGRESS_INDICATOR'
      exporting
        percentage lv_line
        text       'Processing Data........'.
    move-corresponding itab3 to itab2.
    "ship type incoterms1 incoterms2 payment
    read table it_vbkd with  key vbeln itab2-vgbel posnr itab2-vgpos binary search.
    if sy-subrc eq 0.
      itab2-inco1  it_vbkd-inco1 .
      itab2-inco2  it_vbkd-inco2 .
      itab2-zterm  it_vbkd-zterm  .
      itab2-vsart  it_vbkd-vsart .
    else.
      read table it_vbkd with  key vbeln itab2-vgbel posnr '000000' binary search.
      if sy-subrc eq 0.
        itab2-inco1  it_vbkd-inco1 .
        itab2-inco2  it_vbkd-inco2 .
        itab2-zterm  it_vbkd-zterm  .
        itab2-vsart  it_vbkd-vsart .
      endif.
    endif.
    "Check ship type
    check itab2-vsart in s_vsart.
    "Pick status GI billing status
    read table it_vbup1 with  key vbeln itab2-vbeln posnr itab2-posnr binary search.
    if sy-subrc eq 0.
      itab2-kosta it_vbup1-kosta.
      itab2-wbsta it_vbup1-wbsta.
      itab2-fksta it_vbup1-fksta.
    endif.

    "order type
*    perform conversion_order_type using itab2-auart
*                          changing itab2-auart.
    "ship type
    read table it_t173t with key vsart  itab2-vsart binary search .
    if sy-subrc eq 0.
      itab2-bezei it_t173t-bezei.
    endif.
    if itab2-vsart ne itab2-vsart_dn .
      concatenate '* ' itab2-bezei into itab2-bezei.
    endif.
    "pmc remark
    thead-tdname   itab2-vbeln.
    call function 'READ_TEXT'
      exporting
        id        thead-tdid
        language  thead-tdspras
        name      thead-tdname
        object    thead-tdobject
      tables
        lines     lines
      exceptions
        not_found 1
        others    4.
    if not lines[] is  initial.
      loop at lines.
        concatenate itab2-tdline lines-tdline into itab2-tdline separated by space.
      endloop.
    endif.

    "Ship to name
    read table it_kna1 with key  kunnr itab2-kunnr binary search.
    if sy-subrc eq 0.
      itab2-name1 it_kna1-name1.
      itab2-land1 it_kna1-land1.
    endif.
    "sold to name    "M2 add
    read table it_kna1 with key  kunnr itab2-kunnr_sd binary search.
    if sy-subrc eq 0.
      itab2-name_sd it_kna1-name1.
    endif.
    "country
    read table it_t005t with key  land1 itab2-land1 binary search.
    if sy-subrc eq 0.
      itab2-landx it_t005t-landx.
    endif.

    "pick qty
    read table it_vbfa with key  vbelv itab2-vbeln posnv itab2-posnr binary search.
    if sy-subrc eq 0.
      itab2-rfmng it_vbfa-rfmng.
    endif.


    "billing No.
*    if itab2-fksta = 'C'.   "M6 Remark
    clear:lv_bill.                                          "M11 add
    read table  it_vbrp with  key vgbel itab2-vbeln vgpos itab2-posnr .
    if sy-subrc eq 0.
      loop at it_vbrp where vgbel itab2-vbeln and vgpos itab2-posnr. "M7 add
        if it_vbrp-vbeln+0(2'08'  .
          itab2-vbeln_vf it_vbrp-vbeln.
          exit.
        elseif it_vbrp-vbeln+0(2'05'.                   "M11 add
          if lv_bill 'X'.
            exit.
          endif.
          if itab2-vbeln_vf is initial.
            itab2-vbeln_vf it_vbrp-vbeln.
          else.
            lv_bill 'X'.
            concatenate itab2-vbeln_vf '#' into  itab2-vbeln_vf.
          endif.
        endif.

      endloop.
    endif.
*    endif.

    "Unloading Point
    read table  it_vbpa with  key vbeln itab2-vgbel posnr itab2-vgpos   binary search. "M10 Modify
    if sy-subrc eq 0.
      itab2-ablad it_vbpa-ablad.
    endif.

*M4 Add
    "Serial No. Status

    read table gt_serial with  key vbeln itab2-vbeln posnr itab2-posnr binary search.
    if sy-subrc eq 0.
      select single objnr
       into corresponding fields of gt_serial
       from equi
       where matnr itab2-matnr
         and sernr gt_serial-sernr.
      if sy-subrc eq 0.
        call function 'STATUS_TEXT_EDIT'
          exporting
            client           sy-mandt
            objnr            gt_serial-objnr
            bypass_buffer    'X'
            spras            sy-langu
          importing
*           e_stsma          =
            line             gt_serial-status
          exceptions
            object_not_found 1
            others           2.
        if sy-subrc eq 0.
          itab2-status gt_serial-status.
        endif.
      endif.
    endif.
*M4 End
*M5 add
    read table it_vbap with  key vbeln itab2-vgbel posnr itab2-vgpos binary search.
    if sy-subrc eq 0.
      itab2-posex it_vbap-posex.
    endif.
*M5 End
*M8 add
    read table it_mara with  key matnr itab2-matnr binary search.
    if sy-subrc eq 0.
      itab2-ntgew it_mara-ntgew * itab2-lfimg.            "M9 add
      itab2-brgew  it_mara-brgew * itab2-lfimg.           "M9 add
      itab2-volum  it_mara-volum * itab2-lfimg.           "M9 add
      lv_size 0.
      if it_mara-groes is not initial.
        itab2-groes it_mara-groes.
        perform process_num using it_mara-groes
            changing lv_size .
        if lv_size ne 0.
          itab2-ntgew itab2-ntgew / lv_size .
          itab2-brgew itab2-brgew / lv_size .
          itab2-volum itab2-volum / lv_size .
          lv_p  itab2-lfimg / lv_size  .                  "M9 add
          lv_i trunclv_p ).
          if lv_p > lv_i.
            lv_i lv_i + 1.
          endif.
          itab2-ctnno lv_i.                               "M9 add
        endif.
      endif.
    endif.
*M8 End
*M11 add
    if lv_price 'X'.
      read table it_konv with  key knumv =  itab2-knumv  kposn itab2-vgpos binary search.
      if sy-subrc eq 0.
        itab2-kbetr it_konv-kbetr.
        itab2-kpein it_konv-kpein.
      endif.
    endif.

    read table it_knkk with  key kunnr itab2-kunnr_sd binary search.
    if sy-subrc eq 0.
      if it_knkk-klimk ne 0 .
        itab2-klprz it_knkk-sauft + it_knkk-skfor + it_knkk-ssobl 100 /  it_knkk-klimk .
      else.
        itab2-klprz 0.
      endif.
    endif.
    read table it_knkkf1 with  key kunnr itab2-kunnr_sd binary search.
    if sy-subrc eq 0.
      itab2-mahns it_knkkf1-mahns.
    endif.

*M11 end

    "Gross weigth Net weight
    if itab2-gewei 'G'.
      itab2-brgew itab2-brgew / 1000.
      itab2-ntgew itab2-ntgew / 1000.
    endif.

*M3 Modify
    if itab2-uecha is not initial.
      move-corresponding itab2 to it_split.
      append it_split.
      clear:it_split.
    else.
      append itab2.
    endif.
    clear:itab2,lines,lines[],lv_p,lv_i,lv_size.
*M3 end
  endloop.
*M3 modify
  "check split
  itab1[] itab2[].
  clear:itab2,itab2[].
  sort it_split by vbeln uecha posnr.
  loop at itab1 .
    move-corresponding itab1 to itab2.
    read table it_split with key vbeln itab2-vbeln uecha itab2-posnr binary search.
    if sy-subrc eq 0.
      loop at it_split where vbeln itab2-vbeln  and uecha itab2-posnr .
        itab2-lfimg itab2-lfimg + it_split-lfimg.
        itab2-rfmng itab2-rfmng + it_split-rfmng.
        itab2-brgew itab2-brgew + it_split-brgew.
        itab2-ntgew itab2-ntgew + it_split-ntgew.
        itab2-volum itab2-volum + it_split-volum.         "M9 add
        itab2-ctnno itab2-ctnno + it_split-ctnno.         "M9 add
        lv_kosta itab2-kosta .
        lv_wbsta itab2-wbsta .
        lv_fksta itab2-fksta .
        perform get_status using it_split-kosta
                          changing lv_kosta.
        perform get_status using it_split-wbsta
                          changing lv_wbsta.
*        perform get_status using it_split-fksta
*                          changing lv_fksta.          "M7 Remark
*M4 Add Serial No. Status
        if itab2-status is initial .
          itab2-status it_split-status.
        else.
          concatenate itab2-status  it_split-status into   itab2-status  separated by '/'.
        endif.
*M4 End
      endloop.
      itab2-kosta lv_kosta.
      itab2-wbsta lv_wbsta.
*      itab2-fksta = lv_fksta.  "M7 Remark
    endif.
    "Check Pick status GI status Billing status
    check itab2-kosta in s_kosta.
    check itab2-wbsta in s_wbsta.
    check itab2-fksta in s_fksta.
    append itab2.
    clear:itab2,lv_kosta,lv_wbsta,lv_fksta.
  endloop.
  free:it_t173t,it_vbpa,it_vbfa,it_kna1,it_t005t,it_vbrp,it_vbkd,it_vbup1,gt_serial,itab3,itab1.
*M3 end
endform.                    "process_data

 

*&---------------------------------------------------------------------*
*&      Form  display_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form display_data.
  define alv_field.
    clear wa_alv_field1 .
    wa_alv_field1-fieldname     &1.
    wa_alv_field1-edit &2.
    wa_alv_field1-seltext_m &3.
    wa_alv_field1-checkbox      &4."CURR 指定数据类型
    wa_alv_field1-ref_tabname &5 .
    wa_alv_field1-ref_fieldname &6 .
    wa_alv_field1-hotspot       &7.
    wa_alv_field1-outputlen           &8.
    append wa_alv_field1 to  wa_alv_fieldcat1 .
  end-of-definition.
  alv_field   'SEL' 'X' 'Select' 'X' '' '' 'X' '6'.
  alv_field   'KUNNR_SD' '' 'Sold-to' '' 'VBAK' 'KUNNR'  '' '10'.
  alv_field   'KLPRZ' '' 'Credit limit used(%)' '' '' '' '' '10'.  "M11
  alv_field   'NAME_SD' '' 'Sold-to Name' '' '' '' '' '15'.
  alv_field   'KUNNR' '' 'Ship-to' '' 'KUWEV' 'KUNNR'  '' '10'.
  alv_field   'NAME1' '' 'Ship-to Name' '' '' '' '' '15'.
  alv_field   'VKORG' '' 'Location' '' '' '' '' '5'.
  alv_field   'BSTNK' '' 'PO' '' '' '' '' '10'.
  alv_field   'AUART' '' 'Order Type' '' 'VBAK' 'AUART' '' '6'.
  alv_field   'VGBEL' '' 'SO No' '' 'VBAP' 'VBELN' 'X' '10'.
  alv_field   'VBELN' '' 'DN' '' 'LIPS' 'VBELN' 'X' '10'..
  alv_field   'LIFSK' '' 'Block status' '' '' '' '' '6'.
  alv_field   'KOSTA'  '' 'Pick' '' '' '' '' '5'.
  alv_field   'WBSTA'  '' 'GI' '' '' '' '' '3'.
  alv_field   'FKSTA'  '' 'Billing' '' '' '' '' '5'.
  alv_field   'WADAT'  '' 'Planed GI Date' '' '' '' '' '10'.
  alv_field   'WAUHR'  '' 'Planed GI Time' '' '' '' '' '8'.
  alv_field   'WADAT_IST'  '' 'Actual GI date' '' '' '' '' '10'.
  alv_field   'MATNR' '' 'P/N' '' 'MARA' 'MATNR' '' '18'.
  alv_field   'LFIMG' '' 'QTY' '' '' '' '' ''.
  alv_field   'RFMNG'  '' 'Pick qty' '' '' '' '' ''.
  alv_field   'VRKME' '' 'Unit' '' '' '' '' '4'.
  alv_field   'ARKTX' '' 'Desc' '' '' '' '' ''.
  alv_field   'KDMAT' '' 'Cust P/N' '' '' '' '' ''.
  alv_field   'BEZEI' '' 'Shipping type' '' '' '' '' ''.
  alv_field   'NTGEW' '' 'Net weight' '' '' '' '' ''.
  alv_field   'BRGEW' '' 'Gross weight' '' '' '' '' ''.
  alv_field   'VOLUM' '' 'CBM' '' '' '' '' ''.
  alv_field   'ZTERM'  '' 'payment terms' '' '' '' '' ''.
  alv_field   'INCO1'  '' 'incoterms 1' '' '' '' '' ''.
  alv_field   'INCO2'  '' 'incoterms 2' '' '' '' '' ''.
  alv_field   'VBELN_VF' '' 'Billing No.' '' 'VBRP' 'VBELN' 'X' '12'."
  alv_field   'SERNP' '' 'Serial number profile' '' '' '' '' ''.
  alv_field   'LANDX' '' '消费国' '' '' '' '' ''.
  alv_field   'ABLAD' '' 'Unloading Point' '' '' '' '' ''.
  alv_field   'TDLINE' '' 'PMC REMARK' '' '' '' '' ''.
  alv_field   'STATUS' '' 'Serial No. Status' '' '' '' '' ''.
  alv_field   'POSEX' '' 'PO Item' '' '' '' '' '3'.         "M5 add
  alv_field   'VGPOS' '' 'SO Item' '' '' '' '' '3'.         "M8 add
  alv_field   'POSNR' '' 'DN Item' '' '' '' '' '3'.         "M8 add
  alv_field   'GROES' '' 'Size/dimensions' '' '' '' '' ''.  "M8 add
  alv_field   'CTNNO' '' 'Total Carton' '' '' '' '' ''.     "M9 add
*M11 add
  if lv_price 'X'.
    alv_field   'KBETR' '' 'SO Price' '' '' '' '' ''.
    alv_field   'KPEIN' '' 'Price Unit' '' '' '' '' ''.
  endif.
  alv_field   'MAHNS' '' 'Overdue' '' '' '' '' ''.
*M11 end
  data: i_grid_settings type  lvc_s_glay .
  i_grid_settings-edt_cll_cb  'X' .
  data:i_save type c.
  if sy-uname 'JIMMY_WONG' or sy-uname 'OLIVER_LEE'.    "M7 Add
    i_save 'A'.
  else.
    i_save 'U'.
  endif.

  if lw_layout is initial.
    perform set_layout.
  endif.

  sort itab2 by vbeln wadat vgbel matnr.

  call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      i_callback_program       sy-repid
      is_layout                lw_layout
      it_fieldcat              wa_alv_fieldcat1
      i_callback_user_command  'ALV_USER_COMMAND'
*     i_grid_settings          = i_grid_settings
      i_save                   i_save
      i_callback_pf_status_set gs_status
    tables
      t_outtab                 itab2.


endform .                    "display_data

*&---------------------------------------------------------------------*
*&      Form  ALV_USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
form alv_user_command using r_ucomm like sy-ucomm
                  rs_selfield type slis_selfield. "响应ALV点击自定义按钮之后的事件
  data: lv_vbeln_vf like vbrp-vbeln.
  case r_ucomm.
    when '&IC1'.
      if rs_selfield-fieldname ='VBELN' and rs_selfield-value <>''.
        check  rs_selfield-value is not initial.
*M3 Modify
        set parameter id :'VL' field rs_selfield-value .
        if sy-uname+0(3'MST'.
          call transaction 'ZVL02N_PI'  and skip first screen .
        elseif    sy-uname+0(3'MGC'.
          call transaction 'ZVL02N_SHIP'  and skip first screen .
        else.
          call transaction 'VL02N'  and skip first screen .
        endif.
*M3 End
*M2 Add
        wait up to seconds.
        perform change_status using  rs_selfield-value .
        rs_selfield-refresh 'X'.
        rs_selfield-col_stable 'X'.
        rs_selfield-row_stable =  'X'.
*M2 End
      elseif rs_selfield-fieldname ='VGBEL' and rs_selfield-value <>''.
        set parameter id :'AUN' field rs_selfield-value .
        call transaction 'VA03'  and skip first screen .
      elseif rs_selfield-fieldname ='VBELN_VF' and rs_selfield-value <>''.
        lv_vbeln_vf rs_selfield-value.
        set parameter id :'VF' field lv_vbeln_vf .
        call transaction 'VF03'  and skip first screen .
      elseif rs_selfield-fieldname ='SEL'.
        lv_tabix rs_selfield-tabindex.
        perform select_single using lv_tabix.
        rs_selfield-refresh 'X'.
        rs_selfield-col_stable 'X'.
        rs_selfield-row_stable =  'X'.
      endif.
    when 'APPR'.
      read  table itab2 with key sel 'X'.
      if sy-subrc eq 0.
        perform approved_dn.
        rs_selfield-refresh 'X'.
        rs_selfield-col_stable 'X'.
        rs_selfield-row_stable =  'X'.
      endif.
    when 'SELALL'.
      perform select_all.
      rs_selfield-refresh 'X'.
      rs_selfield-col_stable 'X'.
      rs_selfield-row_stable =  'X'.
    when 'DSEALL'.
      perform deselect_all.
      rs_selfield-refresh 'X'.
      rs_selfield-col_stable 'X'.
      rs_selfield-row_stable =  'X'.
*M2 add
    when 'REFRESH'.
      submit zsdrsp001 with s_refsh 'X'
                       with s_ddate in s_ddate
                       with s_spoint in s_spoint
                       with s_sorg in s_sorg
                       with s_chan in s_chan
                       with s_div  in s_div
                       with s_sparty in s_sparty
                       with s_shipt  in s_shipt
                       with s_vbeln in s_vbeln
                       with s_so in s_so
                       with s_kosta in s_kosta
                       with s_wbsta in s_wbsta
                       with s_fksta in s_fksta
                       with s_lifsk in s_lifsk
                       with s_vsart  in s_vsart.
*M2 End
  endcase.
endform.                    "alv_user_command
*&---------------------------------------------------------------------*
*&      Form  SELECT_ALL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form select_all .
  loop at itab2.
    lv_tabix sy-tabix.
    lv_vbeln itab2-vbeln.
    if lv_vbeln+0(2ne '07'.
*M12 remark
*      if itab2-lifsk = 'Z1' and ( itab2-klprz > 100 or itab2-mahns = 3 ). "M11 add
*        continue.
*      endif.
*M12 End
      itab2-sel 'X'.
      modify itab2 index lv_tabix .
    endif.
  endloop.
endform.                    " SELECT_ALL
*&---------------------------------------------------------------------*
*&      Form  DESELECT_ALL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form deselect_all .
  loop at itab2.
    itab2-sel ''.
    modify itab2.
  endloop.
endform.                    " DESELECT_ALL
*&---------------------------------------------------------------------*
*&      Form  frm_pf_status_set
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RT_EXTAB   text
*----------------------------------------------------------------------*
form frm_pf_status_set using rt_extab type slis_t_extab.
  set pf-status 'STANDARD' excluding rt_extab.
endform.                    "frm_pf_status_set
*&---------------------------------------------------------------------*
*&      Form  SET_LAYOUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form set_layout .
  lw_layout-zebra 'X'.
*  lw_layout-colwidth_optimize = 'X'.
*  gs_layout-box_fieldname = 'SEL'.
endform.                    " SET_LAYOUT
*&---------------------------------------------------------------------*
*&      Form  CONVERSION_ORDER_TYPE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_RECORD_AUART_C  text
*      <--P_IT_RECORD_AUART  text
*----------------------------------------------------------------------*
form conversion_order_type  using    p_old
                            changing p_new.
  call function 'CONVERSION_EXIT_AUART_OUTPUT'
    exporting
      input  p_old
    importing
      output p_new.

endform.                    " CONVERSION_ORDER_TYPE
*&---------------------------------------------------------------------*
*&      Form  SELECT_SINGLE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LV_TABIX  text
*----------------------------------------------------------------------*
form select_single  using    p_tabix.
  loop at itab2 into wa_itab  from p_tabix  to p_tabix  .
    lv_vbeln wa_itab-vbeln.
    clear:wa_itab.
  endloop.
  if lv_vbeln+0(2'07'.
    loop at itab2 where vbeln lv_vbeln.
      lv_tabix sy-tabix.
      itab2-sel '' .
      modify itab2 index lv_tabix.
    endloop.
    message 'Can not Approved/Unapproved "30 VTech FOC Return".' type 'S'.
  else.
    loop at itab2 where vbeln lv_vbeln.
      lv_tabix sy-tabix.
      if itab2-sel 'X' .
        itab2-sel '' .
      else.
        itab2-sel 'X' .
      endif.
      modify itab2 index lv_tabix.
    endloop.
  endif.
endform.                    " SELECT_SINGLE
*&---------------------------------------------------------------------*
*&      Form  APPROVED_DN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form approved_dn .
  data: lv_ans type c,
        lv_flag type c,
        lv_msg type length 100.
  clear:it_select,it_select[].
  loop at itab2 where sel 'X'.
    move-corresponding itab2 to it_select.
    collect it_select.
    clear:it_select.
  endloop.

  loop at it_select where sel 'X'.
    lv_vbeln it_select-vbeln.
    clear:lv_ans,lv_flag,lv_msg.
    if lv_vbeln+0(2'07'.
      message 'Can not Approved/Unapproved "30 VTech FOC Return.' type 'S'.
    else.
*M12 Modify
      loop at itab2 where sel 'X' and vbeln lv_vbeln and lifsk 'Z1' and klprz > 100. "M11 add
      endloop.
      if sy-subrc eq 0.
*        message 'Credit limit used more than 100.' type 'S'. "M11 add
        lv_flag 'X'.
        concatenate 'DN:' lv_vbeln 'Credit limit used more than 100, Continue Anyway?'  into lv_msg separated by space .
        perform popup_info using lv_msg  changing lv_ans.
      else.
        read table itab2  with  key   sel 'X'  vbeln lv_vbeln lifsk 'Z1' mahns 3.
        if sy-subrc eq 0.
*          message 'Balance Overdue.' type 'S'.              "M11 add
          lv_flag 'X'.
          concatenate 'DN:' lv_vbeln 'Balance Overdue, Continue Anyway?'  into lv_msg separated by space .
          perform popup_info using lv_msg changing lv_ans.
        endif.
      endif.
      if lv_flag is initial or lv_flag 'X' and lv_ans '1' ).
        submit zdn_block with p_vbeln lv_vbeln and return.
        import is_success from memory id 'DN_STATUS'.
        import p_lifsk from memory id 'BLOCK_FIELD'.
        if is_success eq 'Y'.
          loop at itab2 where vbeln lv_vbeln.
            lv_tabix sy-tabix.
            itab2-lifsk p_lifsk .
            modify itab2 index lv_tabix.
          endloop.
          message 'Approve/Unapprove success.' type 'S'.
        elseif  is_success eq 'D'.
          message 'No Authorization.' type 'S'.
        elseif  is_success eq 'B'.
          message 'The DN had completed.' type 'S'.
        else.
          message 'Approve/Unapprove failure.' type 'S'.
        endif.
      endif.
    endif.
*M12 End
  endloop.
endform.                    " APPROVED_DN
*&---------------------------------------------------------------------*
*&      Form  CHANGE_STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_RS_SELFIELD_VALUE  text
*----------------------------------------------------------------------*
form change_status  using    p_vbeln.
  data:lv_vbeln like lips-vbeln.
  clear:it_vbup,it_vbup[].
  perform add_pre_zero using p_vbeln
                       changing lv_vbeln .
  select a~vbeln a~posnr a~kosta a~wbsta a~fksta b~uecha
      into corresponding fields of table it_vbup
    from vbup as a inner join lips as on a~vbeln b~vbeln and a~posnr b~posnr
    where a~vbeln lv_vbeln .
  sort it_vbup by vbeln uecha posnr.

  loop at itab2 where vbeln lv_vbeln .
    lv_tabix sy-tabix.
*M3 add
    "process split item DN
    read table it_split with  key vbeln itab2-vbeln.
    if sy-subrc eq 0.
      read table it_vbup with  key vbeln itab2-vbeln.
      if sy-subrc eq 0 .
        loop at it_vbup where vbeln itab2-vbeln and posnr itab2-posnr or uecha  itab2-posnr ).
          perform get_status using it_vbup-kosta
                  changing lv_kosta.
          perform get_status using it_vbup-wbsta
                            changing lv_wbsta.
*          perform get_status using it_vbup-fksta   "M7 Remark
*                            changing lv_fksta.
          itab2-kosta lv_kosta.
          itab2-wbsta lv_wbsta.
*          itab2-fksta = lv_fksta.  "M7 Remark
        endloop.
      endif.
    else.
*M3 End
      read table it_vbup with  key vbeln itab2-vbeln
                                posnr itab2-posnr binary search.
      if sy-subrc eq 0.
        itab2-kosta  it_vbup-kosta.  "Pick status
        itab2-wbsta it_vbup-wbsta.   "GI status
*        itab2-fksta = it_vbup-fksta .   "Billing status  "M7 Remark
      endif.
    endif.
    modify itab2 index lv_tabix.
    clear:lv_kosta,lv_wbsta,lv_fksta.
  endloop.
endform.                    " CHANGE_STATUS
*&---------------------------------------------------------------------*
*&      Form  ADD_PRE_ZERO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_RECORD_WEEKS_C  text
*      <--P_IT_RECORD_WEEKS_C  text
*----------------------------------------------------------------------*
form add_pre_zero  using    p_old
                   changing p_new .

  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input  p_old
    importing
      output p_new.
endform.                    " ADD_PRE_ZERO
*&---------------------------------------------------------------------*
*&      Form  GET_STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_SPLIT_KOSTA  text
*      <--P_LV_KOSTA  text
*----------------------------------------------------------------------*
form get_status  using    p_split_field
                 changing p_field.
  if p_field is initial.
    if  p_split_field is not initial.
      p_field =  p_split_field.
    endif.
  else.
    if p_split_field < p_field  .
      p_field =  p_split_field .
    endif.
  endif.
endform.                    " GET_STATUS
*&---------------------------------------------------------------------*
*&      Form  PROCESS_NUM
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LT_GT_DATA_VALUE  text
*      <--P_IT_RECORD_KPEIN  text
*----------------------------------------------------------------------*
form process_num  using    p_value
                  changing p_change.
  data :lv_value type length 30 .
  if p_value cn c_chk_num.
    p_change 0.
  else.
    lv_value  p_value.
    call function 'C14DG_CHAR_NUMBER_CONVERSION'
      exporting
        i_string                   lv_value
      importing
*       E_FLOAT                    =
        e_dec                      p_change
*       E_DECIMALS                 =
      exceptions
        wrong_characters           1
        first_character_wrong      2
        arithmetic_sign            3
        multiple_decimal_separator 4
        thousandsep_in_decimal     5
        thousand_separator         6
        number_too_big             7
        others                     8.
    if sy-subrc 7.
      p_change p_value.
    endif.
  endif.
endform.                    " PROCESS_NUM
*&---------------------------------------------------------------------*
*&      Form  POPUP_Info
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_TEXT     text
*      -->P_ANS      text
*----------------------------------------------------------------------*
form popup_info using p_text
                changing p_ans.

  call function 'POPUP_TO_CONFIRM'
    exporting
      text_question p_text
    importing
      answer        p_ans.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

endform.                    "POPUP_Info

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值