惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

博客园 - 知秋一叶

透视ERP增强 SAP ABAP 点滴记录 计算BOM函数 BADI查找方法 PP几个表关系 SAP/SD - 做SD你要知道的透明表 内表转WORD一法, 可以调用WORD做报表了 SD--va01的屏幕增强 关于SmartForm和ScriptForm的输出格式设置说明 ABAP常用系统变量 ABAP日期函数 sap库存相关表 IDOC实例, Outbound IDOC Aix命令:列出使用内存和Cpu前几位的进程 Provider 错误 '80004005' 未指定的错误 的最终解决方法 SAP取消的凭证信息表 sqlserver实现网络备份 js常用资料 经典正则表达式 (收藏整理)
sap转换成基本订单单位 - 知秋一叶 - 博客园
知秋一叶 · 2010-03-25 · via 博客园 - 知秋一叶

新增function

源码:

 

function zcf_ut_unit_conversion.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     VALUE(MATNR_IMP) LIKE  MARA-MATNR DEFAULT SPACE
*"     VALUE(MEINS_IMP) LIKE  MARA-MEINS DEFAULT SPACE
*"     VALUE(UNIT_NEW_IMP) LIKE  T006-MSEHI
*"     VALUE(UNIT_OLD_IMP) LIKE  T006-MSEHI
*"     VALUE(VALUE_OLD_IMP) TYPE  MENGE_D
*"  EXPORTING
*"     VALUE(VALUE_NEW_EXP) TYPE  MENGE_D
*"  EXCEPTIONS
*"      OVERFLOW
*"----------------------------------------------------------------------

* Lokale Vereinbarungen
  data value_meins_tmp type f.

  if matnr_imp is initial.
    call function 'UNIT_CONVERSION_SIMPLE'
         exporting
              input                = value_old_imp
              round_sign           = 'X'
              unit_in              = unit_old_imp
              unit_out             = unit_new_imp
         importing
              output               = value_new_exp
         exceptions
              conversion_not_found = 01
              division_by_zero     = 02
              input_invalid        = 03
              output_invalid       = 04
              overflow             = 05
              type_invalid         = 06
              units_missing        = 07
              unit_in_not_found    = 08
              unit_out_not_found   = 09.
     if sy-subrc = 5.
       raise overflow.
     endif.
  else.
*   Umrechnung in Basismenge
    call function 'MATERIAL_UNIT_CONVERSION'
         exporting
              matnr                = matnr_imp
              input                = value_old_imp
              meinh                = unit_old_imp
              kzmeinh              = 'X'
              meins                = meins_imp
         importing
              output               = value_meins_tmp
         exceptions
              conversion_not_found = 01
              input_invalid        = 02
              material_not_found   = 03
              meinh_not_found      = 04
              meins_missing        = 05
              no_meinh             = 06
              output_invalid       = 07
              overflow             = 08.
     if sy-subrc = 8.
       raise overflow.
     endif.
*   Umrechnung auf neue Alternativmengeneinheit
    call function 'MATERIAL_UNIT_CONVERSION'
         exporting
              matnr                = matnr_imp
              input                = value_meins_tmp
              meinh                = unit_new_imp
              kzmeinh              = space
              meins                = meins_imp
         importing
              output               = value_new_exp
         exceptions
              conversion_not_found = 01
              input_invalid        = 02
              material_not_found   = 03
              meinh_not_found      = 04
              meins_missing        = 05
              no_meinh             = 06
              output_invalid       = 07
              overflow             = 08.
     if sy-subrc = 8.
       raise overflow.
     endif.
  endif.

endfunction.

   form frm_changeunit  changing value(p_1) value(p_2) value(p_3) .
  data : ls_mgvgw type menge_d."plfh-mgvgw.
  data : ls_meins type mara-meins.
  data : ls_value_new_exp type menge_d."LIKE plfh-mgvgw.
  clear : ls_meins,ls_value_new_exp.
  select single meins
  into ls_meins
  from mara
  where matnr = p_1.
  ls_mgvgw = p_2.
  call function 'ZCF_UT_UNIT_CONVERSION'
    exporting
      matnr_imp     = p_1
      meins_imp     = ls_meins
      unit_new_imp  = ls_meins
      unit_old_imp  = p_3
      value_old_imp = ls_mgvgw
    importing
      value_new_exp = ls_value_new_exp
    exceptions
      overflow      = 1
      others        = 2.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.
  if not ls_value_new_exp is initial.
    p_2 = ls_value_new_exp.
  endif.
  p_3 = ls_meins.
endform.

   perform frm_changeunit changing wa_mseg-matnr wa_mseg-menge wa_mseg-meins .