版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
SAP-BADI屏幕增强实例MB-MIGO-BADI————————————————————————————————作者:————————————————————————————————日期:ﻩ以下根据系统实例做的最终效果:SE11建立数据表,主要是用于存放附加的数据;MANDT MANDT CLNTﻩ3 0ﻩ客户端MBLNRﻩMBLNRﻩCHARﻩ10ﻩ0ﻩ物料凭证编号MJAHR MJAHRﻩNUMCﻩ4 0 物料凭证年度ZEILE MBLPOﻩNUMCﻩ4ﻩ0 物料凭证中的项目BADI_ERFMGﻩERFMGﻩQUANﻩ13 3ﻩ以输入单位计的数量BADI_ERFME ERFME UNIT 3 0ﻩ条目单位建立结构,在屏幕数据交换时使用建立表类型设置关键字段:SE80建立函数组创建屏幕1000,设计格式,插入附加字段创建function:ZJIM_BADI_EXAMPLE_GET_DATA*"----------------------------------------------------------------------ﻭ*"*"Local
interface:ﻭ*"
EXPORTING
*"
REFERENCE(ES_MIGO_BADI_SCREEN_FIELDS)
TYPE
*"
ZJIM_BADI_EXAMPLE_SCREEN_FIELD
*"----------------------------------------------------------------------ﻭ
*
Get
all
data
from
fields
of
external
screen
*
First
move
all
customer-fieldsﻭ
MOVE-CORRESPONDING
zjim_badi_exampl
TO
es_migo_badi_screen_fields.ﻭ*
Second
move
all
GOITEM-fields
(displayed
on
external
screen)function:ZJIM_BADI_EXAMPLE_PUT_DATA*"----------------------------------------------------------------------
*"*"Local
interface:
*"
IMPORTINGﻭ*"
REFERENCE(IS_MIGO_BADI_SCREEN_FIELDS)
TYPE
*"
ZJIM_BADI_EXAMPLE_SCREEN_FIELDﻭ*"----------------------------------------------------------------------ﻭ
*
Put
all
data
from
fields
to
external
screen
*
First
fill
all
customer-fieldsﻭ
MOVE-CORRESPONDING
is_migo_badi_screen_fields
TO
ZJIM_badi_exampl.
*
second
fill
all
GOITEM-fields
(displayed
on
external
screen)function:ZJIM_BADI_EXAMPLE_UPDATE_DATA*"----------------------------------------------------------------------ﻭ*"*"Update
function
module:ﻭ*"ﻭ*"*"Local
interface:ﻭ*"
TABLES
*"
IT_MIGO_BADI_EXAMPLE
STRUCTURE
ZJIM_BADI_EXAMPLﻭ*"----------------------------------------------------------------------
*
Databse
update:
INSERT
zjim_BADI_EXAMPL
FROM
TABLE
IT_MIGO_BADI_EXAMPLE.
IF
sy-subrc
<>
0.ﻭ
MESSAGE
a398(00)
WITH
'Error
update
MIGO_BADI_EXAMPL'.ﻭ
ENDIF.INCLUDE:LZJIM_BADI001TOPTABLES
:
Zjim_badi_exampl.到这里增强的准备工作就做完了,下面开始创建实现:SE19创建实现创建执行类ZCL_IM_JIM_MIGO_BADI,激活ZJIM_MIGO_BADI双击类维护类属性GT_EXTDATA用于数据交换,类型为ZJIM_TY_T_EXTDATA表类型,激活以下方法并维护:method
IF_EX_MB_MIGO_BADI~INIT.
*
Regristration
of
BAdI-Implementation:
*
Append
class
attribute
GF_CLASS_ID
(='MIGO_BADI_IMPLEMENTATION1')
toﻭ*
regristration
table.
APPEND
gf_class_id
TO
ct_init.ﻭendmethod.METHOD
IF_EX_MB_MIGO_BADI~PBO_DETAIL
.ﻭ
DATA:
ls_extdata
TYPE
zjim_badi_example_screen_field.
*
This
check
is
obligatory,
otherwise
the
program
flow
is
incorrect
*
(If
there
would
be
more
than
one
implementation
of
BAdI
MB_MIGO_BADI,
*
only
one
subscreen
would
be
displayed).ﻭ
CHECK
i_class_id
=
gf_class_id.ﻭ*
Show
screen
only
if
there
is
an
item
CHECK
i_line_id
<>
0.ﻭ*
External
subscreen:ﻭ*
The
content
of
global
field
G_NO_INPUT
(set
in
method
MODE_SET)
willﻭ*
influence
the
number
of
external
subsreen:ﻭ
if
g_no_input
is
initial.
e_cprog
=
'SAPLZJIM_BADI001'(006)."程序名为定义的函数组的名称前加“SAPL“。ﻭ
e_dynnr
=
'1000'.
"External
fields:
Inputﻭ
e_heading
=
'ZJIM'(004)."显示标签的名称ﻭ
endif.ﻭ*
Set
G_LINE_ID
(=
line_id
of
item
displayed
on
detail-tabstrip)
g_line_id
=
i_line_id.
*
Read
dataﻭ
READ
TABLE
gt_extdata
INTO
ls_extdata
WITH
TABLE
KEY
line_id
=
i_line_id.
*
Export
data
to
function
group
(for
display
on
subscreen)ﻭ
CALL
FUNCTION
'ZJIM_BADI_EXAMPLE_PUT_DATA'
EXPORTINGﻭ
is_migo_badi_screen_fields
=
ls_extdata.
ENDMETHOD.
"IF_EX_MB_MIGO_BADI~PBO_DETAILMETHOD
IF_EX_MB_MIGO_BADI~PAI_DETAIL
.
*-----------------------------------------------------------------------
*
Changing
parameter
E_FORCE_CHANGE
can
be
set
to
'X'.
In
this
case
*
method
LINE_MODIFY
is
called.ﻭ*
ATTENTION:ﻭ*
DO
NOT
SET
parameter
E_FORCE_CHANGE
=
'
'.
In
this
case
you
might
*
overwrite
parameter
E_FORCE_CHANGE
of
another
BAdI
implementation.ﻭ*-----------------------------------------------------------------------
DATA:
ls_extdata_new
TYPE
zjim_badi_example_screen_field,ﻭ
ls_extdata_old
TYPE
zjim_badi_example_screen_field.
ﻭ*
Only
if
a
line
exists
CHECK
i_line_id
<>
0.
*
Get
data
from
external
screen
CALL
FUNCTION
'ZJIM_BADI_EXAMPLE_GET_DATA'ﻭ
IMPORTINGﻭ
es_migo_badi_screen_fields
=
ls_extdata_new.
*
Compare
new
data
with
old
dataﻭ
READ
TABLE
gt_extdata
INTO
ls_extdata_oldﻭ
WITH
TABLE
KEY
line_id
=
i_line_id.ﻭ
ls_extdata_new-line_id
=
i_line_id.
IF
ls_extdata_old
<>
ls_extdata_new.ﻭ*
If
there
were
any
changes,
it's
obligatory
to
force
MIGO
to
triggerﻭ*
method
LINE_MODIFY.ﻭ
e_force_change
=
'X'.ﻭ
ENDIF.ﻭﻭENDMETHOD.
"IF_EX_MB_MIGO_BADI~PAI_DETAILMETHOD
IF_EX_MB_MIGO_BADI~LINE_MODIFY
.
DATA:
ls_extdata_old
TYPE
zjim_badi_example_screen_field,ﻭ
ls_extdata_new
TYPE
zjim_badi_example_screen_field,
ls_migo_badi_exampl
TYPE
zjim_badi_exampl,
l_subrc
TYPE
sy-subrc.ﻭﻭ*
Get
external
data
from
internal
table:ﻭ
READ
TABLE
gt_extdata
INTO
ls_extdata_old
WITH
TABLE
KEY
line_id
=
i_line_id.ﻭ
l_subrc
=
sy-subrc.
*
Update
data
in
internal
table:ﻭ
IF
l_subrc
<>
0.
*
Line
is
new:
If
GOITEM
has
a
reference
to
a
material
document,ﻭ*
the
already
existing
external
data
can
be
read.ﻭ
IF
NOT
cs_goitem-mblnr
IS
INITIAL
AND
NOT
cs_goitem-mjahr
IS
INITIAL
AND
NOT
cs_goitem-zeile
IS
INITIAL.
SELECT
SINGLE
*
FROM
zjim_badi_exampl
INTO
ls_migo_badi_examplﻭ
WHERE
mblnr
=
cs_goitem-mblnrﻭ
AND
mjahr
=
cs_goitem-mjahrﻭ
AND
zeile
=
cs_goitem-zeile.
IF
sy-subrc
=
0.
MOVE-CORRESPONDING
ls_migo_badi_exampl
TO
ls_extdata_new.
ENDIF.
ENDIF.ﻭ*
ls_extdata_new-sgtxt
=
cs_goitem-sgtxt.
ls_extdata_new-line_id
=
i_line_id.ﻭ
INSERT
ls_extdata_new
INTO
TABLE
gt_extdata.ﻭ
ELSE.
*
Line
exists:
Get
external
data
entered
on
BAdI-subscreeen,
but
only
*
if
line_modify
was
called
for
the
item
displayed
in
the
*
'detail
tabstrip'.ﻭ
check
g_line_id
=
i_line_id.ﻭ
CALL
FUNCTION
'ZJIM_BADI_EXAMPLE_GET_DATA'
IMPORTINGﻭ
es_migo_badi_screen_fields
=
ls_extdata_new.
ls_extdata_new-line_id
=
i_line_id.ﻭ*
if
ls_extdata_new-sgtxt
<>
ls_extdata_old-sgtxt.
**
Field
was
changed
on
external
screenﻭ*
cs_goitem-sgtxt
=
ls_extdata_new-sgtxt.
*
else.
**
Take
data
from
GOITEM
*
ls_extdata_new-sgtxt
=
cs_goitem-sgtxt.
*
endif.ﻭ
MODIFY
TABLE
gt_extdata
FROM
ls_extdata_new.ﻭ
ENDIF.ﻭﻭENDMETHOD.
"IF_EX_MB_MIGO_BADI~LINE_MODIFYMETHOD
IF_EX_MB_MIGO_BADI~LINE_DELETE
.
DELETE
TABLE
gt_extdata
WITH
TABLE
KEY
line_id
=
i_line_id.
ENDMETHOD.
"IF_EX_MB_MIGO_BADI~LINE_DELETEMETHOD
IF_EX_MB_MIGO_BADI~POST_DOCUMENT
.ﻭ
DATA:
ls_migo_badi_example
TYPE
ZJIM_badi_exampl,
lt_migo_badi_example
TYPE
TABLE
OF
zjim_badi_exampl,
ls_extdata
TYPE
zjim_badi_example_screen_field,
ls_xmseg
TYPE
mseg.ﻭ
FIELD-SYMBOLS:
<gt_extdata>
TYPE
migo_badi_example_screen_field.
*
Transaction
MIGO
will
now
post
a
material
document.
*
Any
errors
here
MUST
be
issued
as
A-message
(better:
X-message)ﻭﻭ*
Copy
data
from
material
document
into
internal
table
LOOP
AT
gt_extdata
INTO
ls_extdata.ﻭ
IF
g_cancel
IS
INITIAL.
READ
TABLE
it_mseg
INTO
ls_xmsegﻭ
WITH
KEY
line_id
=
ls_extdata-line_id.ﻭ
ELSE.ﻭ
READ
TABLE
it_mseg
INTO
ls_xmseg
WITH
KEY
smbln
=
ls_extdata-mblnrﻭ
smblp
=
ls_extdata-zeileﻭ
sjahr
=
ls_extdata-mjahr.ﻭ
ENDIF.
IF
sy-subrc
IS
INITIAL.
MOVE-CORRESPONDING
ls_extdata
TO
ls_migo_badi_example.ﻭ
MOVE-CORRESPONDING
ls_xmseg
TO
ls_migo_badi_example.ﻭ
APPEND
ls_m
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2022幼儿园元旦活动总结范文5篇
- 2022年建筑施工工作总结三篇
- 豫满全球电商培训
- 石河子大学《足球》2022-2023学年第一学期期末试卷
- 石河子大学《食品工艺学实验》2022-2023学年第一学期期末试卷
- 石河子大学《心理测量学》2022-2023学年第一学期期末试卷
- 石河子大学《家畜环境卫生学》2023-2024学年第一学期期末试卷
- 石河子大学《法律文书》2023-2024学年期末试卷
- 沈阳理工大学《商务俄语翻译》2023-2024学年第一学期期末试卷
- 沈阳理工大学《建筑设计》2021-2022学年第一学期期末试卷
- DBJ50∕T-346-2020 无障碍设计标准
- 高中信息技术 必修1 数据的分析(课件)
- 校本课程评价表
- 红色经典朗诵稿3-5分钟18篇
- 浅论新时代基层行政管理中依法行政问题及对策-以某市为例 法学专业
- 高中学生创新思维能力现状调查问卷
- 洞口封堵工程(混凝土楼板)施工方案
- 临时便道施工方案47107
- 部编版五年级语文上册单元教材分析全册1-8单元
- 资产评估案例分析-——以贵州茅台酒股份有限公司为例
- TDS-3000B(示波器使用基础知识)ppt课件
评论
0/150
提交评论