TYPES : BEGIN OF TP_EKPO,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
MATNR TYPE MATNR,
MENGE TYPE BSTMG,
MEINS TYPE BSTME,
KNTTP TYPE KNTTP,
PSTYP TYPE PSTYP,
LGORT TYPE LGORT_D,
NETPR TYPE BPREI,
ELIKZ TYPE ELIKZ,
LOEKZ TYPE ELOEK,
WERKS TYPE EWERK,
END OF TP_EKPO.
DATA : T_EKPO TYPE STANDARD TABLE OF TP_EKPO,
WA_EKPO TYPE TP_EKPO.
TYPES : BEGIN OF TP_EKKO,
EBELN TYPE EBELN,
BSART TYPE ESART,
LIFNR TYPE ELIFN,
BUKRS TYPE BUKRS,
EKORG TYPE EKORG,
EKGRP TYPE BKGRP,
INCO1 TYPE INCO1,
INCO2 TYPE INCO2,
ZTERM TYPE DZTERM,
AEDAT TYPE ERDAT,
KNUMV TYPE KNUMV,
WAERS TYPE WAERS,
END OF TP_EKKO.
DATA : T_EKKO TYPE STANDARD TABLE OF TP_EKKO,
WA_EKKO TYPE TP_EKKO.
DATA : W_EBELN TYPE EKKO-EBELN.
CONSTANTS: C_X TYPE C VALUE 'X'.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_EBELN FOR W_EBELN OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK B1.
START-OF-SELECTION.
PERFORM FETCH_DATA.
PERFORM GRDONE_CHECK.
END-OF-SELECTION.
PERFORM CREATE_PO.
*&---------------------------------------------------------------------*
*& Form FETCH_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FETCH_DATA .
SELECT EBELN EBELP MATNR MENGE KNTTP PSTYP
LGORT NETPR ELIKZ LOEKZ WERKS
FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE T_EKPO
WHERE EBELN IN S_EBELN AND ELIKZ NE 'X' AND LOEKZ EQ ' '.
IF T_EKPO IS INITIAL.
" PERFORM error log
ENDIF.
SELECT EBELN BSART LIFNR BUKRS EKORG EKGRP INCO1
INCO2 ZTERM AEDAT KNUMV WAERS
FROM EKKO
INTO TABLE T_EKKO
FOR ALL ENTRIES IN T_EKPO
WHERE EBELN EQ T_EKPO-EBELN.
IF T_EKKO IS INITIAL.
" PERFORM error log
ENDIF.
ENDFORM. " FETCH_DATA
*&---------------------------------------------------------------------*
*& Form GRDONE_CHECK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GRDONE_CHECK .
DATA : TL_XEKBES TYPE STANDARD TABLE OF EKBES WITH HEADER LINE.
DATA : L_IDX TYPE SY-TABIX.
*&---------------------------------------------------------------------*
*& Form CREATE_PO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CREATE_PO .
DATA: WL_HEADER TYPE BAPIMEPOHEADER,
WL_HEADERX TYPE BAPIMEPOHEADERX,
TL_ITEM TYPE STANDARD TABLE OF BAPIMEPOITEM,
TL_ITEMX TYPE STANDARD TABLE OF BAPIMEPOITEMX,
TL_RETURN TYPE STANDARD TABLE OF BAPIRET2,
WL_RETURN TYPE BAPIRET2,
WL_ITEM LIKE BAPIMEPOITEM,
WL_ITEMX LIKE BAPIMEPOITEMX,
L_BUKRS TYPE BUKRS,
L_PONO TYPE EBELN,
L_INT TYPE I.
DATA: BEGIN OF TL_BAPIRETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF TL_BAPIRETURN.
IF L_PONO IS INITIAL.
LOOP AT TL_RETURN INTO WL_RETURN.
WRITE / WL_RETURN-MESSAGE.
CLEAR WL_RETURN.
ENDLOOP.
ULINE.
SKIP.
ELSE.
WRITE : / 'New PO Created Under the number :',
L_PONO HOTSPOT ON.
ULINE.
SKIP.
ENDIF.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.