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 = &1. 
GS_FIELDCAT-SCRTEXT_L = &2. 
GS_FIELDCAT-OUTPUTLEN = &3. 
GS_FIELDCAT-NO_ZERO = &4. 
APPEND GS_FIELDCAT TO GT_FIELDCAT. 
END-OF-DEFINITION. 
SELECTION-SCREEN:BEGIN OF BLOCK BLK01 WITH FRAME TITLE TEXT-001. 
SELECT-OPTIONS:S_BUKRS FOR BKPF-BUKRS DEFAULT '1000'. 
SELECT-OPTIONS:S_GJAHR FOR BKPF-GJAHR DEFAULT SY-DATUM+0(4). 
SELECT-OPTIONS:S_MONAT FOR BKPF-MONAT DEFAULT SY-DATUM+4(2). 
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 = '1' 
AND SKAT~KTOPL = '1000' 
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 = '1'. 
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_CSKT 
FROM CSKT WHERE SPRAS = '1' AND KOKRS = '1000'. 
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 = '0002202002' 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 = '0001406001' 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 * -1. 
GW_SHOW-WRBTRS = GW_SHOW-WRBTR * -1. 
ELSE. 
GW_SHOW-DMBTRH = GW_SHOW-DMBTR * -1. 
GW_SHOW-WRBTRH = GW_SHOW-WRBTR * -1. 
ENDIF. 
GW_SHOW-DMBTR = GW_SHOW-DMBTR * -1. 
GW_SHOW-WRBTR = GW_SHOW-WRBTR * -1. 
*      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 = 0. 
GW_SHOW-TXT40 = GW_T053-TXT40. 
ENDIF. 
READ TABLE GT_CSKT INTO GW_CSKT WITH KEY KOSTL = GW_SHOW-KOSTL. 
IF SY-SUBRC = 0. 
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'             '公司代码'              4   'X', 
'GJAHR'             '会计年度'              4   'X', 
'MONAT'             '会计期间'              2   'X', 
'BUDAT'             '过账日期'              10   '', 
'BELNR'             '凭证编号'              10  'X', 
'AWKEY'             '凭证参考'              20  'X', 
'BKTXT'             '摘要'                  25    '', 
'HKONT'             '科目代码'              10    'X', 
'TXT50'             '科目名称'              50    '', 
'KUNNR'             '客户编号'              10    '', 
'LIFNR'             '供应商编号'            10    '', 
'FKBER'             '功能范围'              4    '', 
'GSBER'             '业务范围'              4    '', 
'WAERS'             '币别'                  3    '', 
'KOSTL'             '成本中心'              10    'X', 
'LTEXT'             '成本中心描述'          40    '', 
'MATNR'             '物料编码'              18    'X', 
'RSTGR'             '原因代码'              4     '', 
'TXT40'             '原因代码描述'          40     '', 
'WRBTR'             '原币金额'              16    '', 
'WRBTRS'            '原币借方金额'          16    '', 
'WRBTRH'            '原币贷方金额'          16    '', 
'DMBTR'             '本币金额'              16    '', 
'DMBTRS'            '本币借方金额'          16    '', 
'DMBTRH'            '本币贷方金额'          16    '', 
'USNAM'             '制单人'                12    ''. 
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            = 1 
OTHERS                   = 2. 
IF SY-SUBRC <> 0. 
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 = 0. 
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.

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/18620.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论