ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 取得open sales order(2) 转

取得open sales order(2) 转

原创 Linux操作系统 作者:ultraluck 时间:2019-07-10 21:00:05 0 删除 编辑

取得open sales order(2)

*&---------------------------------------------------------------------*

*& Form GET_DATA_BQ

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

FORM GET_DATA_BQ.

* With inner join get billing plan

* VBAK--VBAP--VBKD--FPLT

SELECT A~VBELN B~POSNR D~AFDAT D~TETXT D~MLBEZ D~FPROZ

D~FAKWR D~WAERS D~FAKSP D~FAREG D~FKSAF D~ZTERM

D~FPTTP D~FKARV D~KURRF D~MLSTN D~FPFIX

FROM VBAK AS A INNER JOIN VBAP AS B ON B~VBELN = A~VBELN

INNER JOIN VBKD AS C ON C~VBELN = B~VBELN AND C~POSNR = B~POSNR

INNER JOIN FPLT AS D ON D~FPLNR = C~FPLNR

INTO CORRESPONDING FIELDS OF TABLE IT_BQ

WHERE A~VKORG IN S_VKORG

AND A~VTWEG IN S_VTWEG

AND A~SPART IN S_SPART

AND A~KUNNR IN S_KUNNR

AND A~ERDAT IN S_ERDAT

AND A~AUART IN S_AUART

AND B~PSTYV IN S_PSTYV

AND B~ABGRU IN S_ABGRU

AND B~PS_PSP_PNR IN S_WBS

AND B~MATNR IN S_MATNR

AND D~FKSAF <> 'C'.

IF SY-SUBRC <> 0.

MESSAGE S033(/SIE/CHN_ALL)

WITH 'No data exists!'.

ENDIF.

ENDFORM. " GET_DATA_BQ

*&---------------------------------------------------------------------*

*& Form GET_DATA_SQ

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

FORM GET_DATA_SQ.

* Local data

DATA:

BEGIN OF LR_SQ,

VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

RFMNG LIKE VBFA-RFMNG,

KWMENG LIKE VBAP-KWMENG,

OQ LIKE VBAP-KWMENG,

VRKME LIKE VBAP-VRKME,

END OF LR_SQ.

DATA: LIT_SQ LIKE TABLE OF LR_SQ,

LLR_SQ LIKE LR_SQ.

DATA: L_QTY LIKE VBFA-RFMNG.

* Get sales open Qty

* VBAK--VBAP--VBFA

SELECT A~VBELN B~POSNR B~KWMENG B~VRKME C~RFMNG

FROM VBAK AS A INNER JOIN VBAP AS B ON B~VBELN = A~VBELN

INNER JOIN VBFA AS C ON C~POSNV = B~POSNR AND C~VBELV = B~VBELN

INTO CORRESPONDING FIELDS OF TABLE LIT_SQ

WHERE A~VKORG IN S_VKORG

AND A~VTWEG IN S_VTWEG

AND A~SPART IN S_SPART

AND A~KUNNR IN S_KUNNR

AND A~ERDAT IN S_ERDAT

AND A~AUART IN S_AUART

AND B~PSTYV IN S_PSTYV

AND B~ABGRU IN S_ABGRU

AND B~PS_PSP_PNR IN S_WBS

AND B~MATNR IN S_MATNR

AND C~VBTYP_N IN S_VBTYP.

IF SY-SUBRC <> 0.

MESSAGE S033(/SIE/CHN_ALL) WITH 'No data exists!'.

ENDIF.

* GI Qty summary

SORT LIT_SQ BY VBELN POSNR.

LOOP AT LIT_SQ INTO LR_SQ.

LLR_SQ = LR_SQ.

L_QTY = LLR_SQ-RFMNG + L_QTY.

AT END OF POSNR.

LLR_SQ-OQ = LLR_SQ-KWMENG - L_QTY.

WRITE:

L_QTY TO R_SQ-GQ UNIT LLR_SQ-VRKME,

LLR_SQ-KWMENG TO R_SQ-SQ UNIT LLR_SQ-VRKME,

LLR_SQ-OQ TO R_SQ-OQ UNIT LLR_SQ-VRKME.

R_SQ-VBELN = LLR_SQ-VBELN.

R_SQ-POSNR = LLR_SQ-POSNR.

APPEND R_SQ TO IT_SQ.

CLEAR: LLR_SQ,LR_SQ,L_QTY.

ENDAT.

ENDLOOP.

ENDFORM. " GET_DATA_SQ

*&---------------------------------------------------------------------*

*& Form OUTPUT_SQ

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

FORM OUTPUT_SQ.

* Define ALV fieldcat structure

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

* Add data to field catelog

SET_ALV_FIELDCAT:

'VBELN' 'IT_BQ' '1' '12' TEXT-A01,

'POSNR' 'IT_BQ' '2' '10' TEXT-A02,

'SQ' 'IT_BQ' '3' '22' TEXT-A03,

'GQ' 'IT_BQ' '4' '22' TEXT-A04,

'OQ' 'IT_BQ' '5' '20' TEXT-A05.

* Call function to show result

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

IT_FIELDCAT = IT_FIELDCAT

I_SAVE = 'A'

TABLES

T_OUTTAB = IT_SQ.

ENDFORM. " OUTPUT_SQ

*&---------------------------------------------------------------------*

*& Form OUTPUT_BQ

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

FORM OUTPUT_BQ.

* Define ALV fieldcat structure

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

* Add data to field catelog

SET_ALV_FIELDCAT:

'VBELN' 'IT_SQ' '1' '12' TEXT-A01,

'POSNR' 'IT_SQ' '2' '10' TEXT-A02,

'AFDAT' 'IT_SQ' '3' '12' TEXT-B03,

'TETXT' 'IT_SQ' '4' '10' TEXT-B04,

'MLBEZ' 'IT_SQ' '5' '10' TEXT-B05,

'FPROZ' 'IT_SQ' '6' '12' TEXT-B06,

'FAKWR' 'IT_SQ' '7' '22' TEXT-B07,

'WAERS' 'IT_SQ' '8' '10' TEXT-B08,

'FAKSP' 'IT_SQ' '9' '10' TEXT-B09,

'FAREG' 'IT_SQ' '10' '10' TEXT-B10,

'FKSAF' 'IT_SQ' '11' '10' TEXT-B11,

'ZTERM' 'IT_SQ' '12' '10' TEXT-B12,

'FPTTP' 'IT_SQ' '13' '10' TEXT-B13,

'FKARV' 'IT_SQ' '14' '10' TEXT-B14,

'KURRF' 'IT_SQ' '15' '20' TEXT-B15 ,

'MLSTN' 'IT_SQ' '16' '20' TEXT-B16,

'FPFIX' 'IT_SQ' '17' '10' TEXT-B17.

* Call function to show result

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

IT_FIELDCAT = IT_FIELDCAT

I_SAVE = 'A'

TABLES

T_OUTTAB = IT_BQ.

ENDFORM. " OUTPUT_BQ


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

请登录后发表评论 登录
全部评论

注册时间:2004-12-03

  • 博文量
    167
  • 访问量
    125641