SAP_SD常用BAPI

SAP_SD常用BAPI1、创建销售订单:BAPI_SALESORDER_CREATEFROMDAT22、创建退货销售订单:BAPI_CUSTOMERRETURN_CREATE3、根据销售订单生成交货单:BAPI_DELIVERYPROCESSING_EXEC4、修改外向交货单:BAPI_OUTB_DELIVERY_CHANGE5、修改内向交货单:BAPI_INB_DELIVERY_CHANGE6、交…

大家好,又见面了,我是你们的朋友全栈君。

1、创建销售订单:BAPI_SALESORDER_CREATEFROMDAT2
2、创建退货销售订单:BAPI_CUSTOMERRETURN_CREATE
3、根据销售订单生成交货单:BAPI_DELIVERYPROCESSING_EXEC
4、修改外向交货单:BAPI_OUTB_DELIVERY_CHANGE
5、修改内向交货单:BAPI_INB_DELIVERY_CHANGE
6、交货单发货过账:WS_DELIVERY_UPDATE
7、VF01/VF04开票:BAPI_BILLINGDOC_CREATEMULTIPLE
DATA: gt_vbak TYPE TABLE OF vbak WITH HEADER LINE,
      gt_vbap TYPE TABLE OF vbap WITH HEADER LINE,
      gt_billingdatain TYPE TABLE OF bapivbrk WITH HEADER LINE,
      gt_conditiondatain TYPE TABLE OF bapikomv WITH HEADER LINE,
      gt_errors TYPE TABLE OF bapivbrkerrors WITH HEADER LINE.


*-------------------------------------------------------------------------
*            BAPI 赋值
*-------------------------------------------------------------------------
FORM frm_ready_billing .

  DATA: lv_message TYPE bapi_msg.

  REFRESH: gt_vbfa[],gt_likp[].

* "找交货单号
  SELECT * FROM vbfa INTO CORRESPONDING FIELDS OF TABLE gt_vbfa FOR ALL ENTRIES IN gt_alv WHERE vbelv = gt_alv-vbeln AND vbtyp_n = 'J'. IF gt_vbfa[] IS NOT INITIAL. SELECT * FROM likp INTO CORRESPONDING FIELDS OF TABLE gt_likp FOR ALL ENTRIES IN gt_vbfa WHERE vbeln = gt_vbfa-vbeln. ENDIF. "---同一销售组织、开票类型、客户,统一开票 SORT gt_alv BY fkara vkorg kunnr. SORT gt_vbfa BY vbelv. SORT gt_konv BY knumv. LOOP AT gt_alv INTO gw_alv. READ TABLE gt_vbfa WITH KEY vbelv = gw_alv-vbeln BINARY SEARCH. IF sy-subrc = 0. LOOP AT gt_vbfa FROM sy-tabix. IF gt_vbfa-vbelv <> gw_alv-vbeln. EXIT. ENDIF. gv_count = gv_count + 1. gt_billingdatain-ref_doc = gt_vbfa-vbelv. "凭证号 gt_billingdatain-ref_item = gt_vbfa-posnv. gt_billingdatain-doc_number = gt_vbfa-vbeln. "交货单号 gt_billingdatain-itm_number = gt_vbfa-posnn. " gt_billingdatain-doc_type = gw_alv-auart. "销售凭证类型 gt_billingdatain-ref_doc_ca = 'C'. "SD 凭证类别 gt_billingdatain-ordbilltyp = gw_alv-fkara. "开票类型 gt_billingdatain-salesorg = gw_alv-vkorg. "销售组织 READ TABLE gt_vbak WITH KEY vbeln = gw_alv-vbeln BINARY SEARCH. IF sy-subrc = 0. gt_billingdatain-distr_chan = gt_vbak-vtweg. "分销渠道 gt_billingdatain-division = gt_vbak-spart. "产品组 READ TABLE gt_konv WITH KEY knumv = gt_vbak-knumv BINARY SEARCH. IF sy-subrc EQ 0. LOOP AT gt_konv FROM sy-tabix. IF gt_konv-knumv NE gt_vbak-knumv. EXIT. ENDIF. gt_conditiondatain-data_index = gv_count. gt_conditiondatain-cond_curr = gt_konv-waers. APPEND gt_conditiondatain. ENDLOOP. ENDIF. ENDIF. gt_billingdatain-ship_to = gw_alv-kunnr. "客户 gt_billingdatain-sold_to = gt_billingdatain-ship_to. "售达方 gt_billingdatain-bill_to = gt_billingdatain-ship_to. "开票方 gt_billingdatain-payer = gt_billingdatain-ship_to. "付款方 READ TABLE gt_vbkd WITH KEY vbeln = gw_alv-vbeln BINARY SEARCH. IF sy-subrc = 0. gt_billingdatain-payment_terms = gt_vbkd-zterm. "付款方式 gt_billingdatain-incoterms1 = gt_vbkd-inco1. "国际贸易条款1 gt_billingdatain-incoterms2 = gt_vbkd-inco2. "国际贸易条款2 ENDIF. READ TABLE gt_vbap WITH KEY vbeln = gw_alv-vbeln BINARY SEARCH. IF sy-subrc = 0. gt_billingdatain-plant = gt_vbap-werks. "工厂 gt_billingdatain-material = gt_vbap-matnr. "物料 gt_billingdatain-currency = gt_vbap-waerk. "currency ENDIF. gt_billingdatain-req_qty = abs( gt_vbfa-rfmng ). "数量 gt_billingdatain-sales_unit = gt_vbfa-meins. "单位 gt_billingdatain-bill_date = pr_sdate. "开票日期 gt_billingdatain-price_date = pr_sdate. "开票日期 APPEND gt_billingdatain. ENDLOOP. ELSE. CLEAR gt_vbap. " vbap READ TABLE gt_vbap WITH KEY vbeln = gw_alv-vbeln BINARY SEARCH. IF sy-subrc = 0. CLEAR gt_vbap. LOOP AT gt_vbap FROM sy-tabix. IF gt_vbap-vbeln NE gw_alv-vbeln. EXIT. ENDIF. gv_count = gv_count + 1. gt_billingdatain-ref_doc = gt_vbap-vbeln. "凭证号 gt_billingdatain-ref_item = gt_vbap-posnr. gt_billingdatain-doc_number = gt_vbap-vbeln. "交货单号 gt_billingdatain-itm_number = gt_vbap-posnr. gt_billingdatain-doc_type = gw_alv-auart. "销售凭证类型 gt_billingdatain-ref_doc_ca = 'C'. "SD 凭证类别 gt_billingdatain-ordbilltyp = gw_alv-fkara. "开票类型 gt_billingdatain-salesorg = gw_alv-vkorg. "销售组织 READ TABLE gt_vbak WITH KEY vbeln = gw_alv-vbeln BINARY SEARCH. IF sy-subrc = 0. gt_billingdatain-distr_chan = gt_vbak-vtweg. "分销渠道 gt_billingdatain-division = gt_vbak-spart. "产品组 LOOP AT gt_konv FROM sy-tabix. IF gt_konv-knumv NE gt_vbak-knumv. EXIT. ENDIF. gt_conditiondatain-data_index = gv_count. gt_conditiondatain-cond_curr = gt_konv-waers. APPEND gt_conditiondatain. ENDLOOP. ENDIF. gt_billingdatain-ship_to = gw_alv-kunnr. "客户 gt_billingdatain-sold_to = gt_billingdatain-ship_to. "售达方 gt_billingdatain-bill_to = gt_billingdatain-ship_to. "开票方 gt_billingdatain-payer = gt_billingdatain-ship_to. "付款方 READ TABLE gt_vbkd WITH KEY vbeln = gw_alv-vbeln BINARY SEARCH. IF sy-subrc = 0. gt_billingdatain-payment_terms = gt_vbkd-zterm. "付款方式 gt_billingdatain-incoterms1 = gt_vbkd-inco1. "国际贸易条款1 gt_billingdatain-incoterms2 = gt_vbkd-inco2. "国际贸易条款2 ENDIF. READ TABLE gt_vbap WITH KEY vbeln = gw_alv-vbeln BINARY SEARCH. IF sy-subrc = 0. gt_billingdatain-plant = gt_vbap-werks. "工厂 gt_billingdatain-material = gt_vbap-matnr. "物料 gt_billingdatain-currency = gt_vbap-waerk. "currency ENDIF. gt_billingdatain-req_qty = abs( gt_vbap-zmeng ). "数量 gt_billingdatain-sales_unit = gt_vbap-zieme. "单位 gt_billingdatain-bill_date = pr_sdate. "开票日期 gt_billingdatain-price_date = pr_sdate. "开票日期 APPEND gt_billingdatain. ENDLOOP. ENDIF. ENDIF. "---同一销售组织、单据类型、客户,统一开票 AT END OF kunnr. PERFORM frm_order_billing CHANGING lv_message. "开票 CLEAR gt_billingdatain[]. CLEAR gv_count. gv_item = 10. ENDAT. ENDLOOP. * 开票异常 IF NOT gv_flagx IS INITIAL. CONCATENATE '错误:开票失败,' lv_message INTO lv_message. MESSAGE lv_message TYPE cn_fail. * 开票成功 ELSEIF gv_flagw = space AND gv_flagx = space. MESSAGE s284 DISPLAY LIKE cn_succ. * 开票出现错误,但可开票,出警告 ELSEIF NOT gv_flagw IS INITIAL AND gv_flagx = space. CONCATENATE '警告:开票成功,' lv_message INTO lv_message. MESSAGE lv_message TYPE cn_warn. ENDIF. ENDFORM. " FRM_READY_BILLING *------------------------------------------------------------------------- * CALL BAPI *------------------------------------------------------------------------- FORM frm_order_billing CHANGING pv_message. DATA: lt_success TYPE TABLE OF bapivbrksuccess WITH HEADER LINE, lt_return TYPE TABLE OF bapiret1 WITH HEADER LINE. SORT gt_billingdatain BY ref_doc. REFRESH: lt_return[],lt_success[],gt_errors[]. * Test Run CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE' EXPORTING * CREATORDATAIN = testrun = 'X' * posting = 'X' TABLES billingdatain = gt_billingdatain conditiondatain = gt_conditiondatain * CCARDDATAIN = * TEXTDATAIN = errors = gt_errors return = lt_return success = lt_success. IF NOT gt_errors[] IS INITIAL. gv_flagx = cn_flagx. ENDIF. IF NOT lt_return[] IS INITIAL. LOOP AT lt_return WHERE type = 'E'. CONCATENATE lt_return-message ' ' INTO pv_message. ENDLOOP. gv_flagw = cn_flagx. ENDIF. IF gv_flagx IS INITIAL. * Post Run CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE' EXPORTING * CREATORDATAIN = testrun = '' * posting = 'X' TABLES billingdatain = gt_billingdatain conditiondatain = gt_conditiondatain * CCARDDATAIN = * TEXTDATAIN = errors = gt_errors return = lt_return success = lt_success. IF NOT lt_success[] IS INITIAL. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ENDIF. ENDIF. ENDFORM. " FRM_ORDER_BILLING
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/163896.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • import java.util.scanner是什么意思

    import java.util.scanner是什么意思java中的importjava.util.scanner;是一个类,可以用这个类来从控制台写入数据(可以是int,string等类型)例如:​importjava.util.scanner;publicclassdemo{publicstaticvoidmain(string[]wqs){stringmystr=””;system.out.print(“请你输入字符,按回车结束”);scanner

  • findwindow详解_finddevicehasbeendestroyed啥意思

    findwindow详解_finddevicehasbeendestroyed啥意思Normal07.8磅02falsefalsefalse…

  • GPU利用率低的解决办法

    GPU利用率低的解决办法watch-n0.1-dnvidia-smi#检查GPU利用率参数解决办法:1.dataloader设置参数2.增大batchsize3.减少IO操作,比如tensorboard的写入和打印。4.换显卡

  • postgresql 14 服务器打不开的问题(5432服务器端口失败)

    postgresql 14 服务器打不开的问题(5432服务器端口失败)问题描述:(*注服务器端口默认5432,我的端口号是安装时自己改的)*注意:安装到语言选项时选择C而不是默认安装时的警告:postsql安装后步骤出现问题,安装可能未正确完成,启动数据库服务失败解决方案:打开服务找到postgresql-x64这个服务右键属性就的可以启动服务了psql控制台也可以正常进入了:…

  • 有return的情况下try catch finally的执行顺序(最有说服力的总结)

    有return的情况下try catch finally的执行顺序(最有说服力的总结)结论:1、不管有木有出现异常,finally块中代码都会执行;2、当try和catch中有return时,finally仍然会执行;3、finally是在return后面的表达式运算后执行的(此时并没有返回运算后的值,而是先把要返回的值保存起来,管finally中的代码怎么样,返回的值都不会改变,任然是之前保存的值),所以函数返回值是在finally执行前确定的;4、finally

  • scrapy中ROBOTSTXT_OBEY = False,不遵守Robot协议文件的规则

    scrapy中ROBOTSTXT_OBEY = False,不遵守Robot协议文件的规则在scrapy中创建项目以后,在settings文件中有这样的一条默认开启的语句:setting文件中配置:#Obeyrobots.txtrules#默认是True,遵守robots.txt文件中的协议,遵守允许爬取的范围。#设置为False,是不遵守robo协议文件。。。ROBOTSTXT_OBEY=True观察代码可以发现,默认为True,就是要遵守rob…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号