Skip to Content
0
Former Member
Jun 02, 2009 at 06:27 AM

BDc session for MM02

140 Views

Hi all,

I wrote a code for BDC session for tr code 'MM02', but that session is not creating

wit hthe following code. can anyone check the code.

REPORT zmara

NO STANDARD PAGE HEADING LINE-SIZE 255.

TABLES mara.

type-pools : truxs.

TYPES : BEGIN OF ty_mara,

matnr TYPE matnr,

meins TYPE meins,

maktx TYPE maktx,

END OF ty_mara.

DATA : bdctab LIKE bdcdata OCCURS 0 WITH HEADER LINE,

gt_mara TYPE TABLE OF ty_mara, gs_mara TYPE ty_mara.

DATA p_file1 TYPE string.

DATA li_tab_raw_data TYPE truxs_t_text_data.

PARAMETERS : p_file LIKE rlgrap-filename.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

static = 'X'

CHANGING

file_name = p_file.

  • p_file1 = p_file.

START-OF-SELECTION.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

i_line_header = 'X'

i_tab_raw_data = li_tab_raw_data

i_filename = p_file

TABLES

i_tab_converted_data = gt_mara

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*include bdcrecx1.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

  • DEST = FILLER8

group = 'ZMARA'

  • HOLDDATE = FILLER8

keep = 'X'

user = sy-uname

  • RECORD = FILLER1

  • PROG = SY-CPROG

  • DCPFM = '%'

  • DATFM = '%'

  • 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.

*

LOOP AT gt_mara INTO gs_mara.

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MATNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RMMG1-MATNR'

gs_mara-matnr.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(02)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(02)'

'X'.

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

gs_mara-maktx.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = 'MM02'

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

TABLES

dynprotab = bdctab

  • 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.

else.

write : 'Record is updated'.

ENDIF.

ENDLOOP.

*perform bdc_transaction using 'MM01'.

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.

*perform close_group.

&----


*& Form BDC_DYNPRO

&----


  • text

----


  • -->P_0178 text

  • -->P_0179 text

----


FORM bdc_dynpro USING value(p_scr)

value(p_dyn).

bdctab-program = p_scr.

bdctab-dynpro = p_dyn.

bdctab-dynbegin = 'X'.

APPEND bdctab.

CLEAR bdctab.

ENDFORM. " BDC_DYNPRO

&----


*& Form BDC_FIELD

&----


  • text

----


  • -->P_0183 text

  • -->P_0184 text

----


FORM bdc_field USING value(p_fnam)

value(p_fval).

bdctab-fnam = p_fnam.

bdctab-fval = p_fval.

APPEND bdctab.

CLEAR bdctab.

ENDFORM. " BDC_FIELD

Edited by: varisetty madhavi on Jun 2, 2009 8:27 AM