‎2008 Mar 06 11:40 AM
Hi I am trying to create demand in MD61 transaction using BDC session METHOD.
the code i wrote is as bellow..
perform open_group.
loop at gt_final into wa_final.
perform bdc_dynpro using 'SAPMM60X' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RM60X-VERSB'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'AM60X-MATAW'
'X'.
perform bdc_field using 'AM60X-MATNR'
WA_FINAL-MATNR.
perform bdc_field using 'AM60X-WERKS'
'NB5'.
perform bdc_field using 'RM60X-VERSB'
'00'.
perform bdc_field using 'RM60X-DATVE'
'02/29/2008'.
perform bdc_field using 'RM60X-DATBE'
'04/04/2009'.
perform bdc_field using 'RM60X-ENTLU'
'M'.
perform bdc_dynpro using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE'
'=PEIN'.
perform bdc_field using 'BDC_CURSOR'
'PBPT-MATNR(01)'.
perform bdc_dynpro using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE'
'PICK'.
perform bdc_field using 'BDC_CURSOR'
'RM60E-PLNMG(01)'.
perform bdc_field using 'PBPT-VERVS'
'X'.
perform bdc_field using 'RM60E-EDATU(01)'
WA_FINAL-DATE.
perform bdc_field using 'RM60E-PLNMG(01)'
WA_FINAL-QUANTY.
perform bdc_dynpro using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_insert.
refresh gt_BDCDATA.
endloop.
perform close_group.
The problem is... withe this code the session is getting created but the values are not getting papulated into the transaction MD61 from the internal table.. Pls provide the solution for this.
Thanx in Advance,
‎2008 Mar 06 11:46 AM
THERE MAY BE CHANCE NOT REFERING TO THE CORRECT SCREEN OR FIELD
SEE THIS SAMPLE CODE HOW TO WRITE A PROGRAM THIS CAN HELP YOU SOME WHAT
First i will explain the procedure step by step and will send a sample code plz check it once ok..And also i will attach a flat file at the end of SAMPLE CODE CHECK IT ONCE OK..
Steps:
1.Bulid an internal table first according to ur flat file fields.
2.select the flat file by using PARAMETER.
3.And assign that file path to GUI_UPLOAD function module.
4.Call BDC_OPEN_GROUP is used to open the session.
5.loop that flat file data and palce BDC_INSERT funtion module in that loop for uploading data into database table
6.After loop call BDC_CLOSE_GROUP to close the session.
SAMPLE CODE:
REPORT ybdc_session_mm01 NO STANDARD PAGE HEADING LINE-SIZE 255.
-
Global Structure for BDC Data
-
DATA: it_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
-
Internal Table
-
DATA: BEGIN OF itab OCCURS 0,
mbrsh LIKE rmmg1-mbrsh,
mtart LIKE rmmg1-mtart,
maktx LIKE makt-maktx,
meins LIKE mara-meins,
END OF itab.
-
Upload the flat file
-
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename =
'C:\Documents and Settings\Compaq_Owner\Desktop\satish\mm01.txt'
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = itab.
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 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
-
Session Method Starts
BDC_OPEN_GROUP
-
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = 'ychinnu'
HOLDDATE = FILLER8
KEEP = 'X'
USER = SY-UNAME
RECORD = FILLER1
PROG = SY-CPROG
IMPORTING
QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
-
Create BDCDATA Structure
-
*include bdcrecx1.
START-OF-SELECTION.
PERFORM open_group.
loop at itab.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMMG1-MTART'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RMMG1-MBRSH'
itab-mbrsh.
PERFORM bdc_field USING 'RMMG1-MTART'
itab-mtart.
-
After enterning MBRSH,MTART we press enter
-
PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'. "press Enter
PERFORM bdc_field USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
-
View selection (Basic data1)
-
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'"view selection
'X'.
-
Select Tick Mark (ok)
-
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_field USING 'MAKT-MAKTX'
itab-maktx.
PERFORM bdc_field USING 'BDC_CURSOR'
'MARA-MEINS'.
PERFORM bdc_field USING 'MARA-MEINS'
itab-meins.
-
Finally after filling the data we save the data.
-
PERFORM bdc_field USING 'MARA-MTPOS_MARA' "For saving
'NORM'.
PERFORM bdc_transaction USING 'MM01'.
*
PERFORM close_group.
-
BDC_INSERT
-
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
dynprotab = it_bdcdata
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
-
Refresh BDCDATA
-
refresh it_bdcdata.
endloop.
-
Closing BDC Group
-
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
-
Start new screen *
-
FORM bdc_dynpro USING program dynpro.
CLEAR it_bdcdata.
it_bdcdata-program = program.
it_bdcdata-dynpro = dynpro.
it_bdcdata-dynbegin = 'X'.
APPEND it_bdcdata.
ENDFORM. "BDC_DYNPRO
-
Insert field *
-
FORM bdc_field USING fnam fval.
IF FVAL NODATA.
CLEAR it_bdcdata.
it_bdcdata-fnam = fnam.
it_bdcdata-fval = fval.
APPEND it_bdcdata.
ENDIF.
ENDFORM. "BDC_FIELD
-
Flat File
-
*M FERT IRON KG
*M ROH STEEL KG
*M HALB IRON KG
-
‎2008 Mar 06 11:47 AM
‎2008 Mar 06 11:53 AM
put a break point at gui_upload and check the values in internal table.
if the internal table have the values then check the program name and screen number properly.
regards.
santhosh reddy
‎2008 Mar 06 1:24 PM
The data was populated in the internal table mentioned in GUI_UPLOAD FM.
And also the data was populated in BDCDATA table.
finally i executed the program and it created the session, and i m trying to process the session, but the data was not populated in MD61.
In the Log file it shows the error message 'Enter all required fields".
‎2008 Mar 06 1:24 PM
The data was populated in the internal table mentioned in GUI_UPLOAD FM.
And also the data was populated in BDCDATA table.
finally i executed the program and it created the session, and i m trying to process the session, but the data was not populated in MD61.
In the Log file it shows the error message 'Enter all required fields".
‎2008 Mar 06 1:38 PM
its simple u r not passing all the values which are mandatory,
try to insert one record manually which is in u r flat file.
you will get idea where the error is coming.
i think u r uploading session in error screen mode.
do it in all screen mode.
ask u r functional guys for the fields which are mandatory.
even if ur uploading all mandatory, there may be not at the exact field location. check it properly
regards.
santhosh reddy