Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Program for Goods Receipt (Urgent)

Former Member
0 Kudos

Hi All,

I would like to know which program runs when we do a goods receipt using MB01 or MIGO & where can i check the lines of code written for this program. As this program goes & updates the receipt quantity in EKET & EKBE tables, so i would like to know how this is done.

Hope my question is clear, await inputs.

Vivek

1 ACCEPTED SOLUTION

former_member195698
Active Contributor
0 Kudos

In SE93 give the Tcode. You will get the program name in the transaction code details.

Its better to search a BAPI or FM Doing the same work as what MIGO or any other Tcode is doing and check the Documentation for that BAPI/function module

<b>Reward Points if useful</b>

Regards,

Abhishek

Message was edited by:

Abhishek Jolly

4 REPLIES 4

former_member195698
Active Contributor
0 Kudos

In SE93 give the Tcode. You will get the program name in the transaction code details.

Its better to search a BAPI or FM Doing the same work as what MIGO or any other Tcode is doing and check the Documentation for that BAPI/function module

<b>Reward Points if useful</b>

Regards,

Abhishek

Message was edited by:

Abhishek Jolly

0 Kudos

Hi Abhishek,

Thanks for the inputs, the program is SAPMM07M, but it has a lot of code, i am not able to find out where it is updating the EKET table. Actually what i need to know is,

Eg: PO qty = 10 nos.

Delivery Schedule 1 = 5 nos (EKET-ETENR = 0001, EKET-MENGE = 5)

Delivery Schedule 2 = 5 nos (EKET-ETENR = 0002, EKET-MENGE = 5)

So when a goods receipt is done, the program updates EKET-WEMNG for line-1 until EKET-WEMNG = 5, after that it moves to the second line & updates the second line. So i want to know how this logic is implemented.

Hope my problem is clear, await your inputs.

Vivek

Former Member
0 Kudos

Hi,

Vivek i wrote the program for th same thing check it once if helpful plzz reward points

DONT forget to reward PLZZZZ...

REPORT ZCL118_TEST_CREATEGR.

"----


  • *

  • Program Name : Post GR in SAP using data from JDE *

  • SAP Name : ZCL118_TEST_CREATEGR *

  • Created By : Context Labs ( www.contextlabs.in ) *

  • Created On : *

  • *

  • *

  • Selection Screen *

  • *

  • *

  • Program Inputs *

  • JDE GR File : File of GR data received from GR *

  • *

  • Program Output *

  • If errors exits it displays the errors *

  • *

  • Program Result : *

  • GR posted in SAP *

  • Error Processing: *

  • *

************************************************************************

  • Modification Log *

  • Change By | Change Request| Change Description & Reason *

*

*

"----


"----


  • DATA DECLARATION

"----


"----


  • CONSTANTS

"----


DATA:

c_trail_t TYPE c VALUE 'T', " Identifier Trailer

c_data_j TYPE c VALUE 'J', " Identifier Data

c_head_h TYPE c VALUE 'H', " Identifier Header

C_COMCODE(4) TYPE N VALUE '0030', " Company code

C_YP(2) TYPE N VALUE '20', " Constant 20

C_MVT_CODE TYPE BAPI2017_GM_CODE VALUE '05', "Movement type

C_UNDERSCORE TYPE C VALUE '_', " Underscore

C_FTYPE(10) TYPE C VALUE 'ASC'. " File type

DATA:

W_IDENTIFIER TYPE C, "Identifier

W_YEAR(4) TYPE N, " Year

MAT_DOC TYPE BAPI2017_GM_HEAD_RET-MAT_DOC, "Material Doc no

MAT_YEAR TYPE BAPI2017_GM_HEAD_RET-DOC_YEAR,"Mat year

W_FILENAME TYPE STRING. " Filename

"----


  • Structures

"----


  • Structure to store data exactly like the Input/JDE File

DATA:

BEGIN OF S_GET_DATA ,

LINE(130) TYPE C, " To hold the entire line in the

" input given file

END OF S_GET_DATA.

  • BAPI structure for entering table data

DATA:

S_DATA TYPE bapi2017_gm_item_create.

*This structure is going to be used to store errors during document

*posting

DATA:

S_ERRORS TYPE bapiret2.

*This structure is going to be used to import from the bapi function

*module

DATA:

FS_HEADER TYPE BAPI2017_GM_HEAD_RET.

  • BAPI strucures for Header

DATA:

S_HEADER TYPE bapi2017_gm_head_01.

  • Structure for Header Line

DATA:

BEGIN OF S_STRUCTRE_HEADER,

RID, "Record identifier

INTID(8) , "Interafce Id

DATE(8), "Date

TIME(6), "Time

ERSEQ(4), "Error sequence

END OF S_STRUCTRE_HEADER.

  • Structure for Legacy File Trailer Line

DATA:

BEGIN OF S_STRUCTRE_TRAILER,

RID, "Record identifier

REC_COUNT(8), "Record count

END OF S_STRUCTRE_TRAILER.

  • Correct record format for JDE inbound file

DATA:

BEGIN OF S_STRUCTRE_DATA,

RID TYPE C, " Record Type Indicator

MVT_TYPE(3) TYPE C, " Movement Type

LNNO(6) TYPE N, " Line Number

LG_ITEM_NO(18) TYPE C, " Item (Material)

QUAN_RE(13) TYPE N, " Order Quantity (in JDE)

UOM(2) TYPE C, " Unit of Measure (in JDE)

PO_NO(8) TYPE C, " PO Number (in JDE)

DOC_TYPE(2) TYPE C, " Document Type

BUS_UNIT(12) TYPE C, " Business Unit

COM_CODE(5) TYPE C, " Company Code

GR_DATE(6) TYPE C, " Goods Receipt Dt (in JDE)

CUS_NO(8) TYPE C, " Customer

END OF S_STRUCTRE_DATA.

"----


  • Internal Tables

"----


*This Internal Table is going to be used to store errors during document

*posting

DATA:

T_ERRORS LIKE TABLE OF S_ERRORS.

  • BAPI structure for entering table data

DATA:

T_DATA LIKE TABLE OF S_DATA.

  • Internal table for Legacy File Header Line

*DATA:

  • T_STRUCTRE_HEADER LIKE TABLE OF S_STRUCTRE_HEADER.

*Internal table to store correct record format for JDE inbound file

DATA:

T_STRUCTRE_DATA LIKE TABLE OF S_STRUCTRE_DATA.

  • Internal table for Legacy File Trailer Line

*DATA:

  • T_STRUCTRE_TRAILER LIKE TABLE OF S_STRUCTRE_TRAILER.

  • Structure to store data exactly like the Input/JDE File

DATA:

T_GET_DATA LIKE TABLE OF S_GET_DATA.

"----


  • SELECTION SCREEN

"----


PARAMETERS:

P_FNAME(30) TYPE C DEFAULT 'C:\SUNIL\DOWNLOAD12.TXT',

P_PLANT(4) TYPE C DEFAULT '1000',

P_STLOC(4) TYPE C DEFAULT '0001'.

"----


  • START OF SELECTION

"----


START-OF-SELECTION.

W_FILENAME = P_FNAME.

  • This subroutine is used to get the data from the input

  • file into an internal table

PERFORM GET_FILE_DATA TABLES T_GET_DATA

USING W_FILENAME

C_FTYPE.

  • This subroutine is used to get the data from the interanl table

  • into an actual formt required.

PERFORM GET_DATA_FROM_FILE TABLES T_GET_DATA

CHANGING S_STRUCTRE_TRAILER

S_STRUCTRE_HEADER

T_STRUCTRE_DATA.

  • This subroutine is used to get the structre data

PERFORM GET_GOODSMVT_ITEM TABLES T_STRUCTRE_DATA

CHANGING T_DATA.

  • This subroutine is used to create document.

PERFORM POST_DATA TABLES T_DATA

T_ERRORS

USING S_HEADER

C_MVT_CODE

CHANGING FS_HEADER

MAT_DOC

MAT_YEAR.

"----


  • END OF SELECTION.

"----


END-OF-SELECTION.

  • checking whether any errors exits or not.

IF T_ERRORS IS INITIAL.

PERFORM COMMIT. " subroutine to commit the

" changes to the database.

WRITE:/ 'THE NO.OF MAT.DOC CREATED IS', MAT_DOC.

ELSE.

PERFORM OUT_ERRORS TABLES T_ERRORS. "to display errors.

ENDIF. "IF T_ERRORS IS INITIAL.

"----


  • SUBROUTINES.

"----


"----


  • Form GET_FILE_DATA

"----


  • This subroutine uses the FM GUI_UPLOAD to get the data to the

  • into the internal table.

----


  • -->P_T_GET_DATA internal table to get the data

  • -->P_P_FNAME variable to know from where file to be get

----


FORM GET_FILE_DATA TABLES P_T_GET_DATA STRUCTURE S_GET_DATA

USING P_P_FNAME LIKE W_FILENAME

P_FTYPE LIKE C_FTYPE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = P_P_FNAME

FILETYPE = P_FTYPE

tables

data_tab = P_T_GET_DATA

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

IF sy-subrc ne 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF. "IF sy-subrc ne 0.

ENDFORM. " GET_FILE_DATA

"----


*" Form GET_DATA_FROM_FILE

"----


  • This subroutine is used to place data in respective tables like

  • header, data and trailer .

----


  • -->P_T_GET_DATA internal table that has the file data

  • -->P_T_STRUCTRE_HEADER internal table to hold header data

  • -->P_T_STRUCTRE_DATA internal table to hold structre data

  • -->P_T_STRUCTRE_TRAILER internal table to hold trailer data

----


FORM GET_DATA_FROM_FILE TABLES P_T_GET_DATA STRUCTURE S_GET_DATA

CHANGING P_S_STRUCTRE_TRAILER LIKE

S_STRUCTRE_TRAILER

P_S_STRUCTRE_HEADER LIKE

S_STRUCTRE_HEADER

P_T_STRUCTRE_DATA LIKE

T_STRUCTRE_DATA[].

DATA:

LS_GET_DATA LIKE S_GET_DATA,

P_S_STRUCTRE_DATA LIKE S_STRUCTRE_DATA.

LOOP AT P_T_GET_DATA INTO LS_GET_DATA.

W_IDENTIFIER = LS_GET_DATA-LINE+0(1).

CASE W_IDENTIFIER.

WHEN c_head_h.

CLEAR P_S_STRUCTRE_HEADER.

P_S_STRUCTRE_HEADER-RID = LS_GET_DATA-LINE+0(1).

P_S_STRUCTRE_HEADER-INTID = LS_GET_DATA-LINE+1(8).

P_S_STRUCTRE_HEADER-DATE = LS_GET_DATA-LINE+9(8).

P_S_STRUCTRE_HEADER-TIME = LS_GET_DATA-LINE+17(6).

P_S_STRUCTRE_HEADER-ERSEQ = LS_GET_DATA-LINE+23(4).

WHEN c_data_j.

CLEAR S_STRUCTRE_DATA.

P_S_STRUCTRE_DATA-RID = LS_GET_DATA-LINE+0(1).

P_S_STRUCTRE_DATA-MVT_TYPE = LS_GET_DATA-LINE+1(3).

P_S_STRUCTRE_DATA-LNNO = LS_GET_DATA-LINE+4(6).

P_S_STRUCTRE_DATA-LG_ITEM_NO = LS_GET_DATA-LINE+10(18).

P_S_STRUCTRE_DATA-QUAN_RE = LS_GET_DATA-LINE+28(13).

P_S_STRUCTRE_DATA-UOM = LS_GET_DATA-LINE+41(2).

P_S_STRUCTRE_DATA-PO_NO = LS_GET_DATA-LINE+43(8).

P_S_STRUCTRE_DATA-DOC_TYPE = LS_GET_DATA-LINE+51(2).

P_S_STRUCTRE_DATA-BUS_UNIT = LS_GET_DATA-LINE+53(12).

P_S_STRUCTRE_DATA-COM_CODE = LS_GET_DATA-LINE+65(5).

P_S_STRUCTRE_DATA-GR_DATE = LS_GET_DATA-LINE+70(6).

P_S_STRUCTRE_DATA-CUS_NO = LS_GET_DATA-LINE+76(8).

APPEND P_S_STRUCTRE_DATA TO P_T_STRUCTRE_DATA.

WHEN c_trail_t.

  • CLEAR S_STRUCTRE_TRAILER.

P_S_STRUCTRE_TRAILER-RID = LS_GET_DATA-LINE+0(1).

P_S_STRUCTRE_TRAILER-REC_COUNT = LS_GET_DATA-LINE+1(8).

  • APPEND S_STRUCTRE_TRAILER TO P_T_STRUCTRE_TRAILER.

ENDCASE.

ENDLOOP.

ENDFORM. " GET_DATA_FROM_FILE

"----


*" Form GET_GOODSMVT_ITEM

"----


  • This subroutine is used to get the header data for the

  • function module Bapi_goodsmvt_create.

----


  • -->P_T_DATA Internal table that contains the data to be given as

  • to function module

  • -->P_T_STRUCTRE_DATA Internal table that contains data to be

  • formated

----


FORM GET_GOODSMVT_ITEM TABLES P_T_STRUCTRE_DATA STRUCTURE

S_STRUCTRE_DATA

CHANGING P_T_DATA LIKE T_DATA[].

DATA:

LS_STRUCTRE_DATA LIKE S_STRUCTRE_DATA,

P_S_DATA LIKE S_DATA.

LOOP AT P_T_STRUCTRE_DATA INTO LS_STRUCTRE_DATA.

CLEAR P_S_DATA.

P_S_DATA-MATERIAL = LS_STRUCTRE_DATA-LG_ITEM_NO.

P_S_DATA-ENTRY_QNT = LS_STRUCTRE_DATA-QUAN_RE.

P_S_DATA-ENTRY_UOM = LS_STRUCTRE_DATA-UOM.

CONCATENATE LS_STRUCTRE_DATA-PO_NO

LS_STRUCTRE_DATA-DOC_TYPE

INTO P_S_DATA-GR_RCPT.

P_S_DATA-PLANT = P_PLANT.

P_S_DATA-STGE_LOC = P_STLOC.

P_S_DATA-MOVE_TYPE = LS_STRUCTRE_DATA-MVT_TYPE.

CONCATENATE C_YP

LS_STRUCTRE_DATA-GR_DATE+4(2)

INTO W_YEAR.

P_S_DATA-ORDER_ITNO = LS_STRUCTRE_DATA-LNNO.

CONCATENATE C_YP

LS_STRUCTRE_DATA-GR_DATE+4(2)

INTO W_YEAR.

CONCATENATE W_YEAR

LS_STRUCTRE_DATA-GR_DATE+0(2)

LS_STRUCTRE_DATA-GR_DATE+2(2)

INTO S_HEADER-DOC_DATE.

S_HEADER-PSTNG_DATE = SY-DATUM.

IF LS_STRUCTRE_DATA-COM_CODE EQ '00003'.

C_COMCODE = '0030'.

CONCATENATE LS_STRUCTRE_DATA-PO_NO

C_UNDERSCORE

C_COMCODE

INTO P_S_DATA-ITEM_TEXT.

ENDIF. "IF lS_STRUCTRE_DATA-COM_CODE EQ

"00003.

APPEND P_S_DATA TO P_T_DATA.

CLEAR:

P_S_DATA,

LS_STRUCTRE_DATA.

ENDLOOP.

ENDFORM. " GET_GOODSMVT_ITEM

"----


*" Form POST_DATA

"----


  • Subroutine is used to create the document

----


  • -->P_T_DATA Internal table to be given as input

  • -->P_T_ERRORS Internal table to hold errors

  • <--P_FS_HEADER FS to hold headret information

  • <--P_MAT_DOC To hold Material Document no

  • <--P_MAT_YEAR To hold Material year

  • -->P_S_HEADER To give header information

  • -->P_C_MVT_CODE constant that contains Movement code

----


FORM POST_DATA TABLES P_T_DATA STRUCTURE S_DATA

P_T_ERRORS STRUCTURE S_ERRORS

USING P_S_HEADER LIKE S_HEADER

P_C_MVT_CODE LIKE C_MVT_CODE

CHANGING P_FS_HEADER LIKE FS_HEADER

P_MAT_DOC LIKE MAT_DOC

P_MAT_YEAR LIKE MAT_YEAR.

  • The function module posts the GR from the data of

  • the file

  • This FM post the BAPI

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = P_S_HEADER

goodsmvt_code = P_C_MVT_CODE

IMPORTING

GOODSMVT_HEADRET = P_FS_HEADER

MATERIALDOCUMENT = P_MAT_DOC

MATDOCUMENTYEAR = P_MAT_YEAR

tables

goodsmvt_item = P_T_DATA

return = P_T_ERRORS

.

ENDFORM. " POST_DATA

&----


*& Form COMMIT

&----


  • This Subroutine is used to commit the changes to the

  • database

----


  • --> p1 text

  • <-- p2 text

----


FORM COMMIT .

  • This Function Module is used to commit the changes

  • to the database.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

.

ENDFORM. " COMMIT

&----


*& Form OUT_ERRORS

&----


  • Subroutine to write errors.

----


  • -->P_T_ERRORS Internal table that holds the erros information

----


FORM OUT_ERRORS TABLES P_T_ERRORS STRUCTURE S_ERRORS.

  • To wirte the error file

LOOP AT P_T_ERRORS INTO S_ERRORS.

WRITE:/ S_ERRORS-MESSAGE.

ENDLOOP.

ENDFORM. " OUT_ERRORS

0 Kudos

Mr. Sunil,

Thank you for sharing that information with me, but as mentioned in my previous post, i just need to know how the logic of updating the EKET table is implemented. I am writing a query & so need to implement a similar logic.

Hope my problem is clear for you.

Await your guidance.

Vivek