关闭

SAP 取出销售订单的Object Reason的相关信息

标签: SAP Sales Order InfoSAP Sales Order
591人阅读 评论(0) 收藏 举报
分类:
REPORT zsdrp301.

********************************
* INNITIALIZATION
********************************
TABLES : vbak,vbap,kna1,mara,tvagt,cdhdr,cdpos.

TYPES : BEGIN OF ltype_vbkp,
        vbeln  TYPE vbak-vbeln,
        erdat  TYPE vbak-erdat,
        ernam  TYPE vbak-ernam,
        vbtyp  TYPE vbak-vbtyp,
        auart  TYPE vbak-auart,
        vkorg  TYPE vbak-vkorg,
        vtweg  TYPE vbak-vtweg,
        spart  TYPE vbak-spart,
        vkgrp  TYPE vbak-vkgrp,
        vkbur  TYPE vbak-vkbur,
        ihrez  TYPE vbak-ihrez,
        bname  TYPE vbak-bname,
        kunnr  TYPE vbak-kunnr,
        zzoter TYPE vbak-zzoter,
        posnr  TYPE vbap-posnr,
        matnr  TYPE vbap-matnr,
        matkl  TYPE vbap-matkl,
        arktx  TYPE vbap-arktx,
        pstyv  TYPE vbap-pstyv,
        posar  TYPE vbap-posar,
        abgru  TYPE vbap-abgru,
        netwr  TYPE vbap-netwr,
        waerk  TYPE vbap-waerk,
        kwmeng TYPE vbap-kwmeng,
        vrkme  TYPE vbap-vrkme,
        END OF ltype_vbkp.

TYPES : BEGIN OF ltype_kna1,
        kunnr TYPE kna1-kunnr,
        name1 TYPE kna1-name1,
        END OF   ltype_kna1.

TYPES : BEGIN OF ltype_mara,
        matnr TYPE mara-matnr,
        normt TYPE mara-normt,
        END OF   ltype_mara.

TYPES : BEGIN OF ltype_tvagt,
        abgru TYPE tvagt-abgru,
        bezei TYPE tvagt-bezei,
        END OF   ltype_tvagt.

TYPES : BEGIN OF ltype_cdpos,
        objectid TYPE cdpos-objectid,
        changenr TYPE cdpos-changenr,
        END OF   ltype_cdpos.

TYPES : BEGIN OF ltype_cdhdr,
        objectid TYPE cdhdr-objectid,
        udate    TYPE cdhdr-udate,
        END OF   ltype_cdhdr.

TYPES : BEGIN OF ltype_middle,
        objectid TYPE cdpos-objectid,
        END OF   ltype_middle.

DATA : lt_middle TYPE TABLE OF ltype_middle,
        ls_middle LIKE LINE OF  lt_middle.

DATA : lt_vbkp TYPE TABLE OF ltype_vbkp,
       ls_vbkp LIKE LINE OF  lt_vbkp.

DATA : lt_kna1 TYPE TABLE OF ltype_kna1,
       ls_kna1 LIKE LINE OF  lt_kna1.

DATA : lt_mara TYPE TABLE OF ltype_mara,
       ls_mara LIKE LINE OF  lt_mara.

DATA : lt_tvagt TYPE TABLE OF ltype_tvagt,
       ls_tvagt LIKE LINE OF  lt_tvagt.

DATA : lt_cdpos TYPE TABLE OF ltype_cdpos,
       ls_cdpos LIKE LINE OF  lt_cdpos.

DATA : lt_cdhdr TYPE TABLE OF ltype_cdhdr,
       ls_cdhdr LIKE LINE OF  lt_cdhdr.

DATA : lt_display TYPE TABLE OF zssdrp301_struc_list,
       ls_display LIKE  LINE OF lt_display.

********************************
* SELECTION-SCREEN
********************************
SELECTION-SCREEN BEGIN OF BLOCK blk01 WITH FRAME.

SELECT-OPTIONS :

m_vbeln FOR vbap-vbeln,
m_posnr FOR vbap-posnr,
m_erdat FOR vbak-erdat,
m_vkorg FOR vbak-vkorg,
m_abgru FOR vbap-abgru.

SELECTION-SCREEN END OF BLOCK blk01.

IF m_vbeln IS INITIAL AND m_abgru IS INITIAL.

  MESSAGE 'Please input selection option' TYPE 'E'.

ELSE.

  PERFORM frm_get_data.

  PERFORM frm_alv_display.
ENDIF.

********************************
* START OF SELECTION
********************************
FORM frm_get_data.
  CLEAR lt_display[].
  SELECT
      t1~vbeln
      t1~erdat
      t1~ernam
      t1~vbtyp
      t1~auart
      t1~vkorg
      t1~vtweg
      t1~spart
      t1~vkgrp
      t1~vkbur
      t1~ihrez
      t1~bname
      t1~kunnr
      t1~zzoter
      t2~posnr
      t2~matnr
      t2~matkl
      t2~arktx
      t2~pstyv
      t2~posar
      t2~abgru
      t2~netwr
      t2~waerk
      t2~kwmeng
      t2~vrkme
    FROM vbak AS t1 INNER JOIN vbap AS t2 ON t1~vbeln = t2~vbeln
    INTO CORRESPONDING FIELDS OF TABLE lt_display
    WHERE  t1~vbeln IN m_vbeln
    AND   t1~erdat  IN m_erdat
    AND   t1~vkorg  IN m_vkorg
    AND   t2~posnr  IN m_posnr
    AND   t2~abgru  IN m_abgru.

  IF lt_display IS NOT INITIAL.

    CLEAR lt_kna1[].
    SELECT
      kunnr
      name1
    FROM kna1
    INTO CORRESPONDING FIELDS OF TABLE lt_kna1
    FOR ALL ENTRIES IN lt_display
    WHERE kunnr = lt_display-kunnr.

    CLEAR lt_mara[].
    SELECT
      matnr
      normt
    FROM mara
    INTO CORRESPONDING FIELDS OF TABLE lt_mara
    FOR ALL ENTRIES IN lt_display
    WHERE matnr = lt_display-matnr.

    CLEAR lt_tvagt[].
    SELECT
     abgru
     bezei
    FROM tvagt
    INTO CORRESPONDING FIELDS OF TABLE lt_tvagt
    FOR ALL ENTRIES IN lt_display
    WHERE abgru = lt_display-abgru
    AND   spras = sy-langu.

    LOOP AT lt_display INTO ls_display.

      ls_middle-objectid = ls_display-vbeln.

      APPEND ls_middle TO lt_middle.

    ENDLOOP.

    IF lt_middle IS NOT INITIAL .

      CLEAR lt_cdpos.
      SELECT
        objectid
        changenr
      FROM cdpos
      INTO CORRESPONDING FIELDS OF TABLE lt_cdpos
      FOR ALL ENTRIES IN lt_middle
      WHERE objectid = lt_middle-objectid
      AND fname = 'ABGRU'.

    ENDIF.

    IF lt_cdpos IS NOT INITIAL.
      SELECT
        objectid
        udate
      FROM cdhdr
      INTO CORRESPONDING FIELDS OF TABLE lt_cdhdr
      FOR ALL ENTRIES IN lt_cdpos
      WHERE objectid = lt_cdpos-objectid.

    ENDIF.

  ENDIF.

  CLEAR ls_display.
  LOOP AT lt_display INTO ls_display.

    CLEAR ls_kna1.
    READ TABLE lt_kna1 INTO ls_kna1 WITH  KEY kunnr = ls_display-kunnr.
    ls_display-name1 = ls_kna1-name1.

    CLEAR ls_mara.
    READ TABLE lt_mara INTO ls_mara WITH  KEY matnr = ls_display-matnr.
    ls_display-normt = ls_mara-normt.

    CLEAR ls_tvagt.
    READ TABLE lt_tvagt INTO ls_tvagt WITH KEY abgru = ls_display-abgru.
    ls_display-bezei = ls_tvagt-bezei.

    CLEAR ls_cdhdr.
    CLEAR ls_middle.
*  ls_middle-objectid = ls_display-vbeln.
    READ TABLE lt_cdhdr INTO ls_cdhdr WITH KEY objectid = ls_display-vbeln.
    IF ls_display-abgru IS NOT INITIAL.
    ls_display-udate = ls_cdhdr-udate.
    ENDIF.

    MODIFY lt_display FROM ls_display.

  ENDLOOP.
ENDFORM.                    "frm_get_data
*&---------------------------------------------------------------------*
*&      Form  frm_alv_display
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_alv_display .


  DATA : ls_layout   TYPE slis_layout_alv.
  DATA : lt_fieldcat TYPE slis_t_fieldcat_alv.
  DATA : l_repid     TYPE sy-repid.
  PERFORM frm_build_fieldcat CHANGING lt_fieldcat.
  PERFORM frm_build_layout CHANGING ls_layout.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = sy-repid
      it_fieldcat              = lt_fieldcat
      is_layout                = ls_layout
*      i_callback_user_command  = 'FRM_USER_COMMAND'
*     i_callback_pf_status_set = 'FRM_PF_STATUS_SET'
    TABLES
      t_outtab                 = lt_display.

ENDFORM.                    " FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
*&      Form  frm_build_fieldcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->CT_FIELDCAT  text
*----------------------------------------------------------------------*
FORM frm_build_fieldcat  CHANGING ct_fieldcat TYPE slis_t_fieldcat_alv.

  DATA : ls_fieldcat LIKE LINE OF ct_fieldcat.
  REFRESH ct_fieldcat.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name = 'ZSSDRP301_STRUC_LIST'
    CHANGING
      ct_fieldcat      = ct_fieldcat.


*  DELETE ct_fieldcat WHERE fieldname = 'PLANR'.

*  LOOP AT ct_fieldcat INTO ls_fieldcat.
*
*    CASE ls_fieldcat-fieldname.
*      WHEN 'MNG01'.
*        IF sy-langu = '1'.
*          ls_fieldcat-seltext_l = '工单数量'.
*        ELSE.
*          ls_fieldcat-seltext_l = 'Order quantity'.
*          ls_fieldcat-seltext_m = 'Order quantity'.
*          ls_fieldcat-seltext_s = 'Order quantity'.
*        ENDIF.
*    ENDCASE.
*
*    MODIFY ct_fieldcat FROM ls_fieldcat TRANSPORTING seltext_l seltext_m seltext_s.
*
*  ENDLOOP.
ENDFORM.                    "frm_build_fieldcat
*&---------------------------------------------------------------------*
*&      Form  frm_build_layout
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->CS_LAYOUT  text
*----------------------------------------------------------------------*
FORM frm_build_layout  CHANGING cs_layout TYPE slis_layout_alv.

  CLEAR cs_layout.
  MOVE 'X' TO cs_layout-detail_popup.
  MOVE 'X' TO cs_layout-colwidth_optimize.
  MOVE 'COLOR' TO cs_layout-info_fieldname.
*  MOVE 'SELECTED' TO cs_layout-box_fieldname.

ENDFORM.                    " FRM_BUILD_LAYOUT

1
0
查看评论

未清销售订单强制关闭尝试

正常操作方法为VA02 ,在销售订单项目中设置拒绝原因后,在未清清单及MD04中即不会有这笔订单数据。 特殊情况下,VA02更改不了时,尝试强制手工关闭,需操作如下步骤: 1.   VBAP~ABGRU  ,用ME16N 设置拒绝原因   ...
  • itjoy_net
  • itjoy_net
  • 2017-05-27 16:08
  • 615

SAP 销售订单删除及如何查已删除的单

如果订单中产品是按单生产的话,你要先把生产订单删除,然后才能删除订单的项目。 按库存生产的话,删除销售订单跟生产订单没有关系。 都跟交货有关系,即后面要是有交货过帐的话,不能删销售订单。 如果知道被删除的销售订单号,可以随便进入任何一张销售订单,在菜单:环境--更改里面输入被删除的...
  • zhongguomao
  • zhongguomao
  • 2016-01-20 11:01
  • 3122

SAP销售订单关联的生产成本核算

销售订单相关的生产中的预先成本核算  需求等级(Requirement class)使您可以在销售订单中设立一状态,此状态需要一已创建的成本估算。如果成本状态(即将进行成本核算)为销售订单而设置,便不允许有不同的各种作业(例如交货和开票)。 您可以对成本做出计划以便用两种方法产生待发货物料...
  • zhongguomao
  • zhongguomao
  • 2015-12-01 09:05
  • 2277

BAPI_SALESORDER_CREATEFROMDAT2 BAPI创建VA01 销售订单

用bapi创建销售订单 VA01 用的bapi如下 关于定价,可能要多做调试,只能传入COND_VALUE定价比率,而定价值是不可以直接修改的, DATA: header_in        ...
  • zhongguomao
  • zhongguomao
  • 2016-07-01 16:36
  • 1942

SD--批量删除订单

如何在sap应用中批量删除一些错误录入的单据。
  • compassbutton
  • compassbutton
  • 2015-06-15 16:49
  • 2933

SAP--用BAPI-实现销售订单修改-Cond-Value

*&---------------------------------------------------------------------* *&      Form  FRM_CHANGE_SALESORDER *&-----...
  • zhongguomao
  • zhongguomao
  • 2016-07-14 08:37
  • 2047

销售订单增强MV45AFZZ

***INCLUDE MV45AFZZ . ************************************************************************ *        &#...
  • zhongguomao
  • zhongguomao
  • 2016-08-03 10:02
  • 2051

销售订单行项的成本估算及其发布

对于不可配置物料级的标准成本估算,我们知道可以用 ck11n 来做 , 对于销售订单行的估算,可以后台配置成自动估算,也可以用 ck51或ck51n来做手工估算,估算的同时可以做标记。我们知道标准成本在标记后可以做一个发布的动作? 那么销售订单行的估算如何做发布呢? 根据跟踪标准程序发现,当订单行做...
  • fangkailove
  • fangkailove
  • 2010-06-17 14:22
  • 4631

销售订单行项目批量导入(BDC)

*----------------------------------------------------------------------** Program name : ZSD_BDC_ORDERITEM_NEW      ...
  • SAPHOME
  • SAPHOME
  • 2007-12-05 11:06
  • 3395

销售订单发货后能否更改订单行项目数量?

根据设置消息类型进行控制 OVAH message No.: V4 083 (lower than delivery) and V4 096 (higher than delivery) 更改这两个消息类型可以限制超交及行项目数量修改的问题。
  • dylan122738
  • dylan122738
  • 2012-07-31 20:23
  • 3242
    个人资料
    • 访问:23677次
    • 积分:442
    • 等级:
    • 排名:千里之外
    • 原创:21篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条