SAPquery传输及其他记录.docx
《SAPquery传输及其他记录.docx》由会员分享,可在线阅读,更多相关《SAPquery传输及其他记录.docx(16页珍藏版)》请在冰豆网上搜索。
![SAPquery传输及其他记录.docx](https://file1.bdocx.com/fileroot1/2023-3/30/536c7d53-5295-4459-abc0-6ec95da9acf8/536c7d53-5295-4459-abc0-6ec95da9acf81.gif)
SAPquery传输及其他记录
要生成TCODE需要先查看报表名并复制报表名。
表连接,主表对其他表如果一对多会造成主表数据行重复显示。
如果其他表的数据可能为空则需使用外部连接,否则主表数据也不显示。
ZMMRP011采购订单查询报表的代码记录
物料长描述
DATA:
lt_lines TYPE TABLE OF tline WITH HEADER LINE,
l_name TYPE thead-tdname.
"物料长文本
CLEAR:
lt_lines[],
l_name,
LONGTEXT.
l_name = EKPO-matnr.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'GRUN'
language = '1'
name = l_name
object = 'MATERIAL'
TABLES
lines = lt_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT lt_lines.
CONCATENATE LONGTEXT lt_lines-tdline INTO LONGTEXT.
ENDLOOP.
批准日期取法(供应部01审批日期)
SELECT SINGLE MAX( UDATE )
FROM CDPOS AS A
INNER JOIN CDHDR AS B ON A~OBJECTCLAS = B~OBJECTCLAS
AND A~OBJECTID = B~OBJECTID
AND A~CHANGENR = B~CHANGENR
INTO RLDATE
WHERE A~OBJECTCLAS = 'EINKBELEG'
AND A~OBJECTID = EKPO-EBELN
AND A~TABNAME = 'EKKO'
AND FNAME = 'FRGKE'
AND VALUE_OLD = '0'
AND VALUE_NEW = '1'.
已预制未过账发票数量
DATA:
BEGIN OF LT_EKBE1 OCCURS 0,
EBELN TYPE EKBE-EBELN,
EBELP TYPE EKBE-EBELP,
MENGE TYPE EKBE-MENGE,
SHKZG TYPE EKBE-SHKZG,
END OF LT_EKBE1.
REFRESH LT_EKBE1.
SELECT EBELN EBELP MENGE SHKZG
FROM EKBE INTO TABLE LT_EKBE1
WHERE EBELN = EKPO-EBELN
AND EBELP = EKPO-EBELP
AND BEWTP = 'T'.
CLEAR YZFP.
LOOP AT LT_EKBE1.
IF LT_EKBE1-SHKZG EQ 'S'.
YZFP = YZFP + LT_EKBE1-MENGE.
ENDIF.
IF LT_EKBE1-SHKZG EQ 'H'.
YZFP = YZFP - LT_EKBE1-MENGE.
ENDIF.
ENDLOOP.
发票校验数量
DATA:
BEGIN OF LT_EKBE OCCURS 0,
EBELN TYPE EKBE-EBELN,
EBELP TYPE EKBE-EBELP,
MENGE TYPE EKBE-MENGE,
SHKZG TYPE EKBE-SHKZG,
END OF LT_EKBE.
REFRESH LT_EKBE.
SELECT EBELN EBELP MENGE SHKZG
FROM EKBE INTO TABLE LT_EKBE
WHERE EBELN = EKPO-EBELN
AND EBELP = EKPO-EBELP
AND BEWTP = 'Q'.
CLEAR FPJY.
LOOP AT LT_EKBE.
IF LT_EKBE-SHKZG EQ 'S'.
FPJY = FPJY + LT_EKBE-MENGE.
ENDIF.
IF LT_EKBE-SHKZG EQ 'H'.
FPJY = FPJY - LT_EKBE-MENGE.
ENDIF.
ENDLOOP.
待预制发票的数量
CLEAR YZFP1.
IF EKPO-REPOS = 'X'.
YZFP1 = EKET-WEMNG - FPJY - YZFP.
ELSEIF
YZFP1 = 0.
ENDIF.
待预制发票金额(不含税)
CLEAR YZFP1JE.
IF EKPO-REPOS = 'X'.
IF YZFP1 = EKPO-MENGE.
YZFP1JE = EKPO-NETWR.
ELSE.
YZFP1JE = YZFP1 * EKPO-NETPR.
ENDIF.
ELSE.
YZFP1JE = 0.
ENDIF.
待预制发票金额(单价不准确时由总价反推单价)
注:
期初导入订单创建时,将单价写为1,然后输入总价有时会出现bug,系统自动回推的单价不准确。
CLEAR YZFP2JE.
IF EKPO-REPOS = 'X'.
IF YZFP1 = EKPO-MENGE.
YZFP2JE = EKPO-NETWR.
ELSE.
YZFP2JE = YZFP1 * ( EKPO-NETWR / EKPO-MENGE ).
ENDIF.
ELSE.
YZFP2JE = 0.
ENDIF.
待收货标识
DATA l_SL TYPE EKPO-MENGE.
CLEAR:
L_SL,
SHBS.
L_SL = EKPO-MENGE - EKET-WEMNG.
IF EKPO-ELIKZ NE 'X'AND
L_SL > 0.
SHBS = 'X'.
ENDIF.
待预制发票标识
DATA l_SL1 TYPE EKPO-MENGE.
CLEAR:
L_SL1,
YZBS.
L_SL1 = EKET-WEMNG - FPJY - YZFP.
IF EKPO-EREKZ NE 'X'AND
EKPO-REPOS = 'X'AND
L_SL1 > 0.
YZBS = 'X'.
ENDIF.
已创建交货单数量
DATA:
BEGIN OF LT_LIPS OCCURS 0,
VGBEL TYPE LIPS-VGBEL,
VGPOS TYPE LIPS-VGPOS,
LFIMG TYPE LIPS-LFIMG,
END OF LT_LIPS.
REFRESH LT_LIPS.
SELECT VGBEL VGPOS LFIMG
FROM LIPS INTO TABLE LT_LIPS
WHERE VGBEL = EKPO-EBELN
AND VGPOS = EKPO-EBELP.
CLEAR INDM.
LOOP AT LT_LIPS.
INDM = INDM + LT_LIPS-LFIMG.
ENDLOOP.
待创建交货单标识
DATA l_SL2 TYPE EKPO-MENGE.
CLEAR:
L_SL2,
INDMBS.
L_SL2 = EKET-WEMNG - INDM.
IF EKPO-ELIKZ NE 'X'AND
EKPO-WEPOS = 'X'AND
L_SL2 > 0.
INDMBS = 'X'.
ENDIF.
寄售物资当前单价(不含税)
DATA:
LS_A017 TYPE A017.
CLEAR:
LS_A017.
SELECT SINGLE *
FROM A017
INTO LS_A017
WHERE MATNR = EKPO-MATNR
AND ESOKZ = '2'
AND KAPPL = 'M'
AND LIFNR = EKKO-LIFNR
AND DATBI GE EKET-EINDT
AND DATAB LE EKET-EINDT.
IF SY-SUBRC EQ 0 AND
EKPO-PSTYP = 2.
SELECT SINGLE KBETR
FROM KONP
INTO JSDJ
WHERE KNUMH = LS_A017-KNUMH.
JSDJ = JSDJ * 100 / 117.
ELSEIF
JSDJ = 0.
ENDIF.
寄售物资当前金额(不含税)
JSJE = JSDJ * EKPO-MENGE.
需求计划名称
CLEAR XQJHM.
SELECT SINGLE XQJHM
FROM ZMMDG001A
INTO XQJHM
WHERE XQJHH = EKPO-BEDNR.
需求计划类型
CLEAR JHLX.
SELECT SINGLE JHLX
FROM ZMMDG001A
INTO JHLX
WHERE XQJHH = EKPO-BEDNR.
需求计划类型描述
CLEAR JHLXMS.
SELECT SINGLE JHLXMS
FROM ZMMDG001A
INTO JHLXMS
WHERE XQJHH = EKPO-BEDNR.
需求提报人
CLEAR TNAME.
SELECT SINGLE TNAME
FROM ZMMDG001A
INTO TNAME
WHERE XQJHH = EKPO-BEDNR.
提报单位
CLEAR TBDW.
SELECT SINGLE TBDW
FROM ZMMDG001A
INTO TBDW
WHERE XQJHH = EKPO-BEDNR.
提报单位描述
CLEAR TBDWMS.
SELECT SINGLE TBDWMS
FROM ZMMDG001A
INTO TBDWMS
WHERE XQJHH = EKPO-BEDNR.
总账科目
DATA:
L_AWKEY TYPE BKPF-AWKEY,
L_BELNR TYPE BSEG-BELNR.
CONCATENATE MSEG-MBLNR MSEG-MJAHR INTO L_AWKEY.
CLEAR L_BELNR.
SELECT SINGLE BELNR
FROM BKPF
INTO L_BELNR
WHERE AWTYP = 'MKPF'
AND AWKEY = L_AWKEY.
SELECT SINGLE HKONT
FROM BSEG
INTO SAKNR
WHERE BUKRS = MSEG-BUKRS
AND GJAHR = MSEG-MJAHR
AND BELNR = L_BELNR
AND KTOSL NE 'WRX'
AND MATNR = MSEG-MATNR.
总账科目名称
SELECT SINGLE TXT20
FROM SKAT
INTO TXT20
WHERE SAKNR = SAKNR
AND KTOPL EQ 'DLXT'
AND SPRAS = '1'.
(注:
可编辑下载,若有不当之处,请指正,谢谢!
)