Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

BDC 2nd rows is not populated.

Hi all,

Please check the code. If i take the flatfile with 2 rows, each time first row is getting updated. Control is not at all taking the second row. where i am doing the mistake.

flatfile: fields are tabspace separated

c fert demo kg

c fert test kg

REPORT ZMM01_BDC_TEST.

PARAMETER: P_FILE LIKE RLGRAP-FILENAME.

TYPES: BEGIN OF T_MM01,

SECTOR(1),

TYPE(4),

DESC(35),

UNIT(4),

END OF T_MM01.

DATA: ITAB TYPE STANDARD TABLE OF T_MM01,

WA TYPE T_MM01.

DATA: I_BDCDATA TYPE STANDARD TABLE OF BDCDATA,

I_BDCMSGCOLL TYPE STANDARD TABLE OF BDCMSGCOLL,

WA_BDCDATA TYPE BDCDATA,

WA_BDCMSGCOLL TYPE BDCMSGCOLL,

V_MSG(200) .

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

IMPORTING

FILE_NAME = P_FILE.

START-OF-SELECTION.

DATA: P_FILE1 TYPE STRING.

MOVE P_FILE TO P_FILE1.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = P_FILE1

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

READ_BY_LINE = 'X'

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.

LOOP AT ITAB INTO WA.

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'

WA-SECTOR. "'C'.

perform bdc_field using 'RMMG1-MTART'

WA-TYPE. " 'FERT'.

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(01)'

'X'.

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 'MAKT-MAKTX'

WA-DESC." 'for testing'.

perform bdc_field using 'BDC_CURSOR'

'MARA-MEINS'.

perform bdc_field using 'MARA-MEINS'

WA-UNIT. " 'kg'.

perform bdc_field using 'MARA-MTPOS_MARA'

'NORM'.

CALL TRANSACTION 'MM01' USING I_BDCDATA MODE 'A' UPDATE 'S' MESSAGES INTO I_BDCMSGCOLL.

WRITE:/ SY-SUBRC.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = SY-MSGID

NO = SY-MSGNO

V1 = SY-MSGV1

V2 = SY-MSGV2

V3 = SY-MSGV3

V4 = SY-MSGV4

IMPORTING

MSG = V_MSG

EXCEPTIONS

NOT_FOUND = 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.

WRITE:/ V_MSG.

ENDLOOP.

----


  • Start new screen *

----


form bdc_dynpro using program dynpro.

clear WA_bdcdata.

WA_bdcdata-program = program.

WA_bdcdata-dynpro = dynpro.

WA_bdcdata-dynbegin = 'X'.

append WA_bdcdata TO I_BDCDATA.

endform.

----


  • Insert field *

----


form bdc_field using fnam fval.

clear WA_bdcdata.

WA_bdcdata-fnam = fnam.

WA_bdcdata-fval = fval.

append WA_bdcdata TO I_BDCDATA.

endform.

Thanks

Krupali

Tags:
Former Member
Former Member replied

After loop at itab.

refresh : I_BDCDATA

Regards

MD

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question