ABAP面试问题及侧重点

ABAP面试

1.简单的Report包括哪些东西

2.Dialog 逻辑流以及相应的处理内容

3.用过的几种增强方式:怎么找增强

4.接口和函数的使用,一般遇到自己不会的函数怎么处理

5.关联查询:INNER JOIN 与 LEFT JOIN 与 FOR ALL ENTRIES IN各用在什么情况

ABAP基础:报表,功能,增强,接口,数据处理及性能优化(不管内部还是外部,均需了解)

REPORT:1)数据定义;定义内表,结构,选择屏幕

2)数据处理;包括屏幕数据检查,数据查询,内表数据处理等

3)数据显示;定义字段目录,布局,特殊设置,CALL FM(习惯用REUSE_ALV_GRID_DISPLAY_LVC,LVC后期兼容和修改方便,也可以替代OO alv )

DIALOG:这是SAP的精华之一,不懂DIALOG,不入SAP门。

1)PBO;数据显示前处理,循环数据显示处理;循环之后无效修改和处理

2)PAI;表行,字段处理,更新表行;事件处理

增强:出口,BADI,隐式(常用的三种);前两种可以用程序找(下篇文章),也可以找到程序对应的包,然后包里搜;隐式增强就是触发事件,DEBUG找地方加代码。

接口:就是查询,处理。。。都会的

查询:INNER 和LEFT,right是且与或的关系,确定都有的INNER,不确定有的,LEFT,RIGHT。文本表不建议关联,适合单独查。

FOR ALL ENTRIES IN使用前最好对关键字排重,非空检查;内表超过10万不建议使用。

常规的性能优化:先查,后处理,LOOP下面尽量不用SELECT和LOOP,READ TABLE 要二分法排序;内表查询确定字段以及顺序,CORRESPONDING FIELDS使用时字段不要多。

考的都是基本的东西,考学习面,学习深度,学习能力,以及对SAP的认识和自己的思维逻辑能力

附简单查询代码:凭证明细报表

*&---------------------------------------------------------------------*
*& Report ZFIR025
*&
*&---------------------------------------------------------------------*
*&
*&DESC :凭证明细表
*
*&AUTHOR: LY
*&
*&DATE:20160721
*&
*&
*&CHANGE LIST
*& C DEVK901712 2016.07.21 08:11:04 LIYUAN
*& C DEVK901869 2016.08.22 15:37:14 LIYUAN 增加本币金额
*&---------------------------------------------------------------------* REPORT ZFIR025. TABLES:BKPF,BSEG,SKAT. TYPES:BEGIN OF TY_SHOW,
MONAT TYPE BKPF-MONAT,
BUDAT TYPE BKPF-BUDAT,
BELNR TYPE BKPF-BELNR,
BUKRS TYPE BKPF-BUKRS,
BKTXT TYPE BKPF-BKTXT,
GJAHR TYPE BKPF-GJAHR,
BLART TYPE BKPF-BLART,
WAERS TYPE BKPF-WAERS,
USNAM TYPE BKPF-USNAM,
AWKEY TYPE BKPF-AWKEY,
HKONT TYPE BSEG-HKONT,
KUNNR TYPE BSEG-KUNNR,
LIFNR TYPE BSEG-LIFNR,
KOSTL TYPE BSEG-KOSTL,
FKBER TYPE BSEG-FKBER,
WRBTR TYPE BSEG-WRBTR,
WRBTRS TYPE BSEG-WRBTR,
WRBTRH TYPE BSEG-WRBTR,
SHKZG TYPE BSEG-SHKZG,
MATNR TYPE BSEG-MATNR,
XNEGP TYPE BSEG-XNEGP,
RSTGR TYPE BSEG-RSTGR, "原因代码
TXT40 TYPE T053S-TXT40, "原因代码文本
LTEXT TYPE CSKT-LTEXT, "成本中心文本
DMBTR TYPE BSEG-DMBTR,
DMBTRS TYPE BSEG-DMBTR,
DMBTRH TYPE BSEG-DMBTR,
TXT50 TYPE SKAT-TXT50,
GSBER TYPE BSEG-GSBER,
END OF TY_SHOW,
BEGIN OF TY_T053S,
RSTGR TYPE BSEG-RSTGR, "原因代码
BUKRS TYPE BSEG-BUKRS, "原因代码
TXT40 TYPE T053S-TXT40, "原因代码文本
END OF TY_T053S,
BEGIN OF TY_CSKT,
KOSTL TYPE BSEG-KOSTL, "原因代码
LTEXT TYPE CSKT-LTEXT, "原因代码文本
END OF TY_CSKT. DATA:GT_SHOW TYPE TABLE OF TY_SHOW,
GW_SHOW LIKE LINE OF GT_SHOW,
GT_T053 TYPE TABLE OF TY_T053S,
GW_T053 LIKE LINE OF GT_T053,
GT_CSKT TYPE TABLE OF TY_CSKT,
GW_CSKT LIKE LINE OF GT_CSKT. DATA:GT_FIELDCAT TYPE LVC_T_FCAT.
DATA GS_FIELDCAT LIKE LINE OF GT_FIELDCAT.
DATA LS_LAYOUT TYPE LVC_S_LAYO. DEFINE APPEND_FIELDCAT .
CLEAR GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = &.
GS_FIELDCAT-SCRTEXT_L = &.
GS_FIELDCAT-OUTPUTLEN = &.
GS_FIELDCAT-NO_ZERO = &.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
END-OF-DEFINITION. SELECTION-SCREEN:BEGIN OF BLOCK BLK01 WITH FRAME TITLE TEXT-.
SELECT-OPTIONS:S_BUKRS FOR BKPF-BUKRS DEFAULT ''.
SELECT-OPTIONS:S_GJAHR FOR BKPF-GJAHR DEFAULT SY-DATUM+().
SELECT-OPTIONS:S_MONAT FOR BKPF-MONAT DEFAULT SY-DATUM+().
SELECT-OPTIONS:S_BELNR FOR BKPF-BELNR.
SELECT-OPTIONS:S_HKONT FOR BSEG-HKONT.
SELECT-OPTIONS:S_KUNNR FOR BSEG-KUNNR.
SELECT-OPTIONS:S_LIFNR FOR BSEG-LIFNR.
SELECT-OPTIONS:S_KOSTL FOR BSEG-KOSTL.
SELECT-OPTIONS:S_BLART FOR BKPF-BLART.
SELECT-OPTIONS:S_BUDAT FOR BKPF-BUDAT.
SELECT-OPTIONS:S_GSBER FOR BSEG-GSBER.
SELECTION-SCREEN END OF BLOCK BLK01. START-OF-SELECTION.
PERFORM PRM_GET_DATA.
PERFORM PRM_PROCE_DATA.
PERFORM PRM_SET_FIELD.
PERFORM PRM_SHOW. *&---------------------------------------------------------------------*
*& Form PRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PRM_GET_DATA .
SELECT
BKPF~MONAT" TYPE BKPF-MONAT,
BKPF~BUDAT" TYPE BKPF-BUDAT,
BKPF~BELNR" TYPE BKPF-BELNR,
BKPF~BUKRS" TYPE BKPF-BUKRS,
BKPF~BKTXT" TYPE BKPF-BKTXT,
BKPF~GJAHR" TYPE BKPF-GJAHR,
BKPF~BLART" TYPE BKPF-BLART,
BKPF~WAERS" TYPE BKPF-WAERS,
BKPF~USNAM" TYPE BKPF-USNAM,
BKPF~AWKEY" TYPE BKPF-USNAM,
BSEG~HKONT" TYPE BSEG-HKONT,
BSEG~KOSTL" TYPE BSEG-HKONT,
BSEG~KUNNR" TYPE BSEG-HKONT,
BSEG~LIFNR" TYPE BSEG-HKONT,
BSEG~FKBER" TYPE BSEG-HKONT,
BSEG~WRBTR" TYPE BSEG-WRBTR,
BSEG~MATNR" TYPE BSEG-WRBTR,
BSEG~SHKZG" TYPE BSEG-WRBTR,
BSEG~XNEGP" TYPE BSEG-WRBTR,
BSEG~RSTGR" TYPE BSEG-RSTGR,
BSEG~DMBTR
SKAT~TXT50" TYPE SKAT-TXT50,
BSEG~GSBER
INTO CORRESPONDING FIELDS OF TABLE GT_SHOW
FROM BKPF
INNER JOIN BSEG
ON BKPF~BUKRS = BSEG~BUKRS
AND BKPF~BELNR = BSEG~BELNR
INNER JOIN SKAT
ON BSEG~HKONT = SKAT~SAKNR
AND SKAT~SPRAS = ''
AND SKAT~KTOPL = ''
WHERE BKPF~BUKRS IN S_BUKRS
AND BKPF~GJAHR IN S_GJAHR
AND BKPF~MONAT IN S_MONAT
AND BKPF~BELNR IN S_BELNR
AND BSEG~HKONT IN S_HKONT
AND BSEG~KUNNR IN S_KUNNR
AND BSEG~LIFNR IN S_LIFNR
AND BSEG~KOSTL IN S_KOSTL
AND BSEG~GSBER IN S_GSBER
AND BKPF~BLART IN S_BLART
AND BKPF~BUDAT IN S_BUDAT. IF GT_SHOW[] IS INITIAL.
MESSAGE '无结果!' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_T053
FROM T053S WHERE SPRAS = ''. SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_CSKT
FROM CSKT WHERE SPRAS = '' AND KOKRS = ''.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form PRM_PROCE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PRM_PROCE_DATA .
DATA:GS_SHOW LIKE LINE OF GT_SHOW. * SORT GT_SHOW BY BUKRS GJAHR BELNR KUNNR DESCENDING LIFNR DESCENDING." HKONT DESCENDING. LOOP AT GT_SHOW INTO GW_SHOW.
* IF GW_SHOW-XNEGP = 'X'.
* GW_SHOW-DMBTR = GW_SHOW-DMBTR * -1.
* ENDIF.
IF GW_SHOW-HKONT = '' AND GW_SHOW-LIFNR IS INITIAL."应付暂估 带出供应商
SELECT SINGLE LIFNR INTO GW_SHOW-LIFNR FROM BSEG WHERE BUKRS = GW_SHOW-BUKRS AND BELNR = GW_SHOW-BELNR AND GJAHR = GW_SHOW-GJAHR AND LIFNR <> ''.
ENDIF. IF GW_SHOW-HKONT = '' AND GW_SHOW-KUNNR IS INITIAL."应付暂估 带出供应商
SELECT SINGLE KUNNR INTO GW_SHOW-KUNNR FROM BSEG WHERE BUKRS = GW_SHOW-BUKRS AND BELNR = GW_SHOW-BELNR AND GJAHR = GW_SHOW-GJAHR AND KUNNR <> ''.
ENDIF.
IF GW_SHOW-SHKZG = 'S'.
IF GW_SHOW-XNEGP = 'X'.
GW_SHOW-DMBTRH = GW_SHOW-DMBTR.
GW_SHOW-WRBTRH = GW_SHOW-WRBTR.
ELSE.
GW_SHOW-DMBTRS = GW_SHOW-DMBTR.
GW_SHOW-WRBTRS = GW_SHOW-WRBTR.
ENDIF.
* GW_SHOW-DMBTRS = GW_SHOW-DMBTR.
ELSEIF GW_SHOW-SHKZG = 'H'. IF GW_SHOW-XNEGP = 'X'.
GW_SHOW-DMBTRS = GW_SHOW-DMBTR * -.
GW_SHOW-WRBTRS = GW_SHOW-WRBTR * -.
ELSE.
GW_SHOW-DMBTRH = GW_SHOW-DMBTR * -.
GW_SHOW-WRBTRH = GW_SHOW-WRBTR * -.
ENDIF. GW_SHOW-DMBTR = GW_SHOW-DMBTR * -.
GW_SHOW-WRBTR = GW_SHOW-WRBTR * -.
* GW_SHOW-DMBTRH = GW_SHOW-DMBTR.
ENDIF. READ TABLE GT_T053 INTO GW_T053 WITH KEY BUKRS = GW_SHOW-BUKRS RSTGR = GW_SHOW-RSTGR.
IF SY-SUBRC = .
GW_SHOW-TXT40 = GW_T053-TXT40.
ENDIF. READ TABLE GT_CSKT INTO GW_CSKT WITH KEY KOSTL = GW_SHOW-KOSTL.
IF SY-SUBRC = .
GW_SHOW-LTEXT = GW_CSKT-LTEXT.
ENDIF. MODIFY GT_SHOW FROM GW_SHOW.
CLEAR:GW_SHOW.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form PRM_SET_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PRM_SET_FIELD .
REFRESH GT_FIELDCAT.
LS_LAYOUT-CWIDTH_OPT = 'X'. "优化列宽选项是否设置
LS_LAYOUT-ZEBRA = 'X'.
* ls_layout-box_fname = 'SEL'.
APPEND_FIELDCAT:'BUKRS' '公司代码' 'X',
'GJAHR' '会计年度' 'X',
'MONAT' '会计期间' 'X',
'BUDAT' '过账日期' '',
'BELNR' '凭证编号' 'X',
'AWKEY' '凭证参考' 'X',
'BKTXT' '摘要' '',
'HKONT' '科目代码' 'X',
'TXT50' '科目名称' '',
'KUNNR' '客户编号' '',
'LIFNR' '供应商编号' '',
'FKBER' '功能范围' '',
'GSBER' '业务范围' '',
'WAERS' '币别' '',
'KOSTL' '成本中心' 'X',
'LTEXT' '成本中心描述' '',
'MATNR' '物料编码' 'X',
'RSTGR' '原因代码' '',
'TXT40' '原因代码描述' '',
'WRBTR' '原币金额' '',
'WRBTRS' '原币借方金额' '',
'WRBTRH' '原币贷方金额' '',
'DMBTR' '本币金额' '',
'DMBTRS' '本币借方金额' '',
'DMBTRH' '本币贷方金额' '',
'USNAM' '制单人' ''.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form PRM_SHOW
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PRM_SHOW .
DATA:LV_TITLE TYPE LVC_TITLE. DESCRIBE TABLE GT_SHOW LINES LV_TITLE.
CONDENSE LV_TITLE NO-GAPS. CONCATENATE '结果共' LV_TITLE '条目!' INTO LV_TITLE. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PRM_SET_STATUS'
I_CALLBACK_USER_COMMAND = 'PRM_USER_COMMAND'
IS_LAYOUT_LVC = LS_LAYOUT
IT_FIELDCAT_LVC = GT_FIELDCAT[]
I_GRID_TITLE = LV_TITLE
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = GT_SHOW
EXCEPTIONS
PROGRAM_ERROR =
OTHERS = .
IF SY-SUBRC <> .
ENDIF.
ENDFORM.
FORM PRM_SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'ZSTAT'.
ENDFORM.
FORM PRM_USER_COMMAND USING P_UCOMM LIKE SY-UCOMM
P_SELFIELD TYPE SLIS_SELFIELD. CHECK P_UCOMM = '&IC1'. READ TABLE GT_SHOW INTO GW_SHOW INDEX P_SELFIELD-TABINDEX.
IF SY-SUBRC = .
SET PARAMETER ID 'BLN' FIELD GW_SHOW-BELNR.
SET PARAMETER ID 'BUK' FIELD GW_SHOW-BUKRS.
SET PARAMETER ID 'GJR' FIELD GW_SHOW-GJAHR. CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDIF.
ENDFORM.
上一篇:解决checkbox的attr(checked)一直为undefined问题


下一篇:Dynamic-Link Library Redirection