ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 在SAP中通过批输入实现拣配

在SAP中通过批输入实现拣配

原创 Linux操作系统 作者:ultraluck 时间:2019-05-03 16:33:06 0 删除 编辑
SAP的批输入并不复杂,本程序比较精采的是利用特殊的屏幕跳转移动,解决了在不同分辨率的机器上批输入参数不同的问题。值得参考。

SAP的批输入并不复杂,本程序比较精采的是利用特殊的屏幕跳转移动,解决了在不同分辨率的机器上批输入参数不同的问题。值得参考。

REPORT ZJP NO STANDARD PAGE HEADING LINE-SIZE 95 MESSAGE-ID Z1.
*&---------------------------------------------------------------------&
* For CPZX Only Programmed by Paul Feng(FQ)
* Created Date 2003.06.20
* Last Modify 2004.12.10
*&---------------------------------------------------------------------&

TABLES: LIKP,LIPS,VBUP.

DATA: BEGIN OF RECORD OCCURS 0,
VBELN(010),
MATNR(018),
LFIMG(013),
PIKMG(017),
end of record.
DATA: SENDTO(10),
LGORT(004).

INCLUDE .
include bdcrecx1.

SELECTION-SCREEN BEGIN OF BLOCK JHD WITH FRAME TITLE TEXT-001.

PARAMETERS: JHD(10) OBLIGATORY.

*SELECTION-SCREEN SKIP 8.

SELECTION-SCREEN END OF BLOCK JHD.

INITIALIZATION.

GET PARAMETER ID 'ZMM' FIELD GROUP.

start-of-selection.
DATA: N(4) TYPE N, LINE(2) TYPE N, JUMP TYPE N.

CONDENSE JHD NO-GAPS.

N = 10 - STRLEN( JHD ).

IF N NE 0.
DO N TIMES.
CONCATENATE '0' JHD INTO JHD.
ENDDO.
ENDIF.

SELECT SINGLE * FROM LIKP WHERE VBELN EQ JHD.
IF SY-SUBRC >< 0.
SHIFT JHD LEFT DELETING LEADING '0'.
WRITE:/ ICON_INCOMPLETE AS ICON,
'交货单' ,JHD COLOR 2,'不存在!' .
STOP.
ELSE.
SENDTO = LIKP-KUNNR.
ENDIF.
CLEAR LIKP.

SELECT * FROM VBUP WHERE VBELN EQ JHD AND KOSTA EQ 'C'.
IF SY-SUBRC EQ 0.
SHIFT JHD LEFT DELETING LEADING '0'.
WRITE:/ ICON_MESSAGE_CRITICAL_SMALL AS ICON,
'交货单',JHD COLOR 2,'已经被拣配!请检查。'.
STOP.
ENDIF.
ENDSELECT.
CLEAR VBUP.

CASE SENDTO.
WHEN '0000004001'.
LGORT = '0800'.
WHEN '0000004002'.
LGORT = '0801'.
WHEN '0000004007'.
LGORT = '0808'.
WHEN '0000004008'.
LGORT = '0809'.
WHEN OTHERS.
WRITE:/ ICON_MESSAGE_WARNING_SMALL AS ICON,
'交货单中“送达方”错误!请检查。' COLOR 6 INVERSE.
STOP.
ENDCASE.

SELECT * FROM LIPS WHERE VBELN EQ JHD.
RECORD-VBELN = LIPS-VBELN.
RECORD-MATNR = LIPS-MATNR.
RECORD-LFIMG = LIPS-LFIMG.
RECORD-PIKMG = LIPS-LFIMG. "按交货数拣配
APPEND RECORD.
ENDSELECT.
CLEAR LIPS.

DESCRIBE TABLE RECORD LINES N.

IF N EQ 0.
SHIFT JHD LEFT DELETING LEADING '0'.
WRITE: ICON_SYSTEM_HELP AS ICON,
'交货单',JHD COLOR 2,'中没有可供拣配的行项目!'.
STOP.
ENDIF.

DATA: FLAG TYPE N VALUE 0.
PERFORM CHECKKC TABLES RECORD USING FLAG.
IF FLAG EQ 1.
CLEAR RECORD.
STOP.
ENDIF.

perform open_group.

perform bdc_dynpro using 'SAPMV50A' '0101'.
perform bdc_field using 'BDC_CURSOR'
'LIKP-VBELN'.
perform bdc_field using 'BDC_OKCODE'
'=UEKO'.
PERFORM BDC_FIELD USING 'LIKP-VBELN'
RECORD-VBELN.

PERFORM BDC_DYNPRO USING 'SAPMV50A' '0220'.

LINE = 0.
N = 0.
JUMP = 0.
DATA : JUMPTO(4) TYPE C.
LOOP AT RECORD.

LINE = LINE + 1.
N = N + 10.

IF JUMP EQ 1.

PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=POPO'.
PERFORM BDC_DYNPRO USING 'SAPMV50A' '0111'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RV50A-POSNR'.
JUMPTO = N.
SHIFT JUMPTO LEFT DELETING LEADING '0'.

PERFORM BDC_FIELD USING 'RV50A-POSNR'
JUMPTO.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.

PERFORM BDC_DYNPRO USING 'SAPMV50A' '0220'.

JUMP = 0.

ENDIF.

DATA: F1(18).
CONCATENATE 'LIPSD-PIKMG(' LINE ')' INTO F1.

PERFORM BDC_FIELD USING 'BDC_CURSOR' F1.
* 'LIPSD-PIKMG(01)'.
perform bdc_field using 'BDC_OKCODE'
'=UEKO'.
DATA: F2(18).
CONCATENATE 'LIPS-LGORT(' LINE ')' INTO F2.
PERFORM BDC_FIELD USING F2 " 'LIPS-LGORT(01)'
LGORT.
DATA: F3(18).
CONCATENATE 'LIPSD-PIKMG(' LINE ')' INTO F3.

PERFORM BDC_FIELD USING F3 " 'LIPSD-PIKMG(01)'
RECORD-PIKMG.

CHECK LINE EQ 12.
LINE = 0.
JUMP = 1.

ENDLOOP.
CLEAR F1.
CLEAR F2.
CLEAR F3.

PERFORM BDC_DYNPRO USING 'SAPMV50A' '0220'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=WABU'.
PERFORM BDC_TRANSACTION USING 'VL02'.

perform close_group.

REFRESH RECORD.
CLEAR RECORD.

SHIFT JHD LEFT DELETING LEADING '0'.

ULINE.

N = N DIV 10.

WRITE: / ICON_GREEN_LIGHT AS ICON,
'交货单', JHD , '成功拣配!会话条目共:', N , '项!'.
WRITE: / ICON_GREEN_LIGHT AS ICON,
'会话名称:',GROUP COLOR 4 INTENSIFIED.

SET PF-STATUS '100'.

AT USER-COMMAND.
IF SY-UCOMM EQ 'EXECUTE'.

SUBMIT RSBDCSUB WITH MAPPE = GROUP WITH VON = SY-DATUM WITH
BIS = SY-DATUM WITH Z_VERARB = 'X'
WITH FEHLER = ''.

ENDIF.

*&---------------------------------------------------------------------*
*& Form CHECKKC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_RECORD text
* <--P_FLAG text
*----------------------------------------------------------------------*
FORM CHECKKC TABLES P_RECORD STRUCTURE RECORD USING P_FLAG.
TABLES: MARD.
DATA: ERRMESS(90) TYPE C.

LOOP AT RECORD.
SELECT SINGLE * FROM MARD WHERE MATNR EQ RECORD-MATNR AND
WERKS EQ '2010' AND
LGORT EQ LGORT.
IF SY-SUBRC EQ 0.
IF MARD-LABST < RECORD-LFIMG.
IF P_FLAG EQ 0.
MOVE 1 TO P_FLAG.
WRITE:/ ICON_MESSAGE_WARNING AS ICON,
'交货单需求项目不足' COLOR 3 INTENSIFIED OFF.
ULINE.
ENDIF.
ERRMESS = P_RECORD-MATNR.
SHIFT ERRMESS LEFT DELETING LEADING '0'.
CONDENSE ERRMESS NO-GAPS.
CONCATENATE '物料:' ERRMESS ' 在工厂:2010 库存地:' LGORT
' 数量不足!' INTO ERRMESS.
WRITE: / ICON_INCOMPLETE AS ICON, ERRMESS
COLOR 5 INTENSIFIED OFF.
ENDIF.
ELSE.
IF P_FLAG EQ 0.
MOVE 1 TO P_FLAG.
WRITE:/ ICON_MESSAGE_WARNING AS ICON,
'交货单需求项目不足' COLOR 3 INTENSIFIED OFF.
ULINE.
ENDIF.
ERRMESS = P_RECORD-MATNR.
SHIFT ERRMESS LEFT DELETING LEADING '0'.
CONDENSE ERRMESS NO-GAPS.
CONCATENATE '物料:' ERRMESS ' 在工厂:2010 库存地:' LGORT
' 不存在!' INTO ERRMESS.
WRITE:/ ICON_MESSAGE_ERROR_SMALL AS ICON,ERRMESS COLOR 2.
ENDIF.
ENDLOOP.

CLEAR ERRMESS.
CLEAR MARD.
ENDFORM. " CHECKKC

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/190059/viewspace-476568/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 基础知识1
请登录后发表评论 登录
全部评论

注册时间:2004-12-03

  • 博文量
    135
  • 访问量
    97385