Application Development and Automation 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: 
Read only

BDC1

Former Member
0 Likes
1,063

Hi,

Please help me on Batch Input program? How to do? Please don’t send any link.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
974

Hi Friend,

If help full then give me max reward point.

A batch input recording is a sequence of transactions with the screens

they have run through. A screen (program name, screen number) contains

the modified fields (field name and value), the user command executed

(BDC_OKCODE) and the cursor position (BDC_CURSOR).

The recording is stored in the database under a 12-digit name. You can

get a list of available recordings on the initial screen (overview).

You can change a batch input recording using the recording editor. You

can also use the export / import interface to do this.

From an existing recording you can create a batch input session, a data

transfer program, test data or a function module to transfer the data:

1. Generating a batch input session directly

The data from the recording is transferred to the batch input

session. You can then process the batch input session for test

purposes using the usual mechanism in Transaction SM35.

2. Creating a data transfer program

When you create a data transfer program, you can decide whether

fixed data is to be transferred from the recording, or whether

variable data should be read from a sequential file.

In the first case, the program must still be modified so that you

can transfer variable data.

In the second case, the system creates a structure in the program

using which one data record is read from the sequential file. The

file access operations (OPEN, READ, CLOSE) are automatically in the

program. A no data character (that can be specified during the

program flow) controls whether a component of the structure should

be occupied or simply ignored.

In the program you have created, you can decide whether the batch

input data transfer should occur using CALL TRANSACTION USING, or

using the traditional batch input session method.

Creating test data

To test the batch input program you have created (see above), you

can create a data record in a sequential file. This data record

contains all field contents from the recording that are relevant to

the data transfer.

Creating a function module for data transfer

The function module you have created contains as an interface all

fields from the recording that are relevant to the data transfer.

The function module imports the data transferred using the batch

input mechanism (CALL TRANSACTION USING or generate session). In

this way, you can import data from a different system (Remote

Function Call) and ensure that the data remains consistent.In the program you have created, you can decide whether the batch

3 REPLIES 3
Read only

Former Member
0 Likes
974

transaction SM35

Menu "go to recording"

push button "create new recording"

Fill in XK01 and start filling the screens as if you would post data manually.

Once a recording was created, you can generate an abap program automatically: position on your recording and press the "create program" button...

This will generate a sample code

Read only

Former Member
0 Likes
975

Hi Friend,

If help full then give me max reward point.

A batch input recording is a sequence of transactions with the screens

they have run through. A screen (program name, screen number) contains

the modified fields (field name and value), the user command executed

(BDC_OKCODE) and the cursor position (BDC_CURSOR).

The recording is stored in the database under a 12-digit name. You can

get a list of available recordings on the initial screen (overview).

You can change a batch input recording using the recording editor. You

can also use the export / import interface to do this.

From an existing recording you can create a batch input session, a data

transfer program, test data or a function module to transfer the data:

1. Generating a batch input session directly

The data from the recording is transferred to the batch input

session. You can then process the batch input session for test

purposes using the usual mechanism in Transaction SM35.

2. Creating a data transfer program

When you create a data transfer program, you can decide whether

fixed data is to be transferred from the recording, or whether

variable data should be read from a sequential file.

In the first case, the program must still be modified so that you

can transfer variable data.

In the second case, the system creates a structure in the program

using which one data record is read from the sequential file. The

file access operations (OPEN, READ, CLOSE) are automatically in the

program. A no data character (that can be specified during the

program flow) controls whether a component of the structure should

be occupied or simply ignored.

In the program you have created, you can decide whether the batch

input data transfer should occur using CALL TRANSACTION USING, or

using the traditional batch input session method.

Creating test data

To test the batch input program you have created (see above), you

can create a data record in a sequential file. This data record

contains all field contents from the recording that are relevant to

the data transfer.

Creating a function module for data transfer

The function module you have created contains as an interface all

fields from the recording that are relevant to the data transfer.

The function module imports the data transferred using the batch

input mechanism (CALL TRANSACTION USING or generate session). In

this way, you can import data from a different system (Remote

Function Call) and ensure that the data remains consistent.In the program you have created, you can decide whether the batch

Read only

Former Member
0 Likes
974

REPORT YGV_BDC_FINAL

NO STANDARD PAGE HEADING

LINE-SIZE 160

LINE-COUNT 65.

DATA: FLAG.

tables: T100.

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

  • Internal Tables

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

DATA: i_bdc_table like bdcdata occurs 0 with header line,

IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

DATA: BEGIN of i_upload occurs 0,

kunnr(10),

vkorg(4),

vtweg(2),

matnr(18),

kdmat(35),

END of i_upload.

DATA: BEGIN of i_table occurs 0,

kunnr(10),

vkorg(4),

vtweg(2),

matnr(18),

kdmat(35),

END of i_table.

*SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.

*PARAMETERS :

*BDCGRP LIKE IBIPPARMS-BDCGRP RADIOBUTTON GROUP MODE,

**CALLTRAN LIKE IBIPPARMS-CALLTRAN DEFAULT 'X' RADIOBUTTON GROUP MODE

*.

***API_FLAG LIKE IBIPPARMS-API_FLAG RADIOBUTTON GROUP MODE.

*SELECTION-SCREEN END OF BLOCK B2.

*Selection-Screen begin of block b1 with frame title text-001.

*

*parameters: p_fname like ibipparms-path.

*

*Selection-Screen end of block b1.

*

*AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_Fname.

  • CALL FUNCTION 'F4_FILENAME'

  • EXPORTING

  • FIELD_NAME = 'P_FNAME'

  • IMPORTING

  • FILE_NAME = P_fname.

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

*Start-of-selection.

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

Start-of-selection.

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

  • Upload a Flat File

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

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'd:\mohit\book1.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = '#'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = i_upload

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.

*write: 'Uploading Was Successful'.

ENDIF.

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

  • Open BDC session

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

Perform create_bdc_records.

i_table[] = i_upload[].

commit work and wait.

Sort i_upload by kunnr vkorg vtweg.

delete adjacent duplicates from i_upload comparing kunnr vkorg vtweg.

Sort i_table by kunnr vkorg vtweg matnr.

Loop at i_upload.

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

  • Insert the data into BDCDATA and process

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

perform bdc_process.

perform bdc_insert.

endloop.

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

  • Close the session

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

if FLAG = 'X'.

perform bdc_close.

clear flag.

endif.

Form create_bdc_records.

if not i_upload[] is initial.

FLAG = 'X'.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

  • DEST = FILLER8

GROUP = 'TEST'

  • HOLDDATE = FILLER8

KEEP = 'X'

USER = sy-uname

  • RECORD = FILLER1

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

*else.

  • write: " file is not uploaded".

endif.

endform.

&----


*& Form bdc_process

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bdc_process.

DATA : FNAM(20) TYPE C,

IDX(2) TYPE C,

ikunnr(10) TYPE C,

imatnr(18) TYPE C,

l_mstring(250) type c.

ikunnr = i_upload-kunnr.

*imatnr = i_table-matnr.

refresh I_bdc_table.

clear i_bdc_table.

perform bdc_dynpro using 'SAPMV10A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'MV10A-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = i_upload-kunnr

IMPORTING

OUTPUT = i_upload-kunnr.

perform bdc_field using 'MV10A-KUNNR'

i_upload-kunnr.

perform bdc_field using 'MV10A-VKORG'

i_upload-vkorg.

perform bdc_field using 'MV10A-VTWEG'

i_upload-vtweg.

perform bdc_dynpro using 'SAPMV10A' '0200'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

MOVE 1 TO IDX.

LOOP AT I_table WHERE kunnr = ikunnr

AND vkorg = i_upload-vkorg

AND vtweg = i_upload-vtweg.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

INPUT = i_table-matnr

IMPORTING

OUTPUT = i_table-matnr.

CONCATENATE 'MV10A-MATNR(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

I_TABLE-MATNR.

CONCATENATE 'MV10A-KDMAT(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

I_TABLE-KDMAT.

IDX = IDX + 1.

ENDLOOP.

ENDFORM. " bdc_process

&----


*& Form bdc_insert

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bdc_insert.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'VD51'

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

TABLES

DYNPROTAB = i_bdc_table

EXCEPTIONS

INTERNAL_ERROR = 1

NOT_OPEN = 2

QUEUE_ERROR = 3

TCODE_INVALID = 4

PRINTING_INVALID = 5

POSTING_INVALID = 6

OTHERS = 7

.

IF SY-SUBRC eq 0.

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

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

ENDIF.

ENDFORM. " bdc_insert

&----


*& Form bdc_close

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bdc_close.

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.

ENDFORM. " bdc_close

FORM bdc_dynpro USING p_g_program_1

p_g_screen.

CLEAR i_bdc_table.

i_bdc_table-program = p_g_program_1.

i_bdc_table-dynpro = p_g_screen.

i_bdc_table-dynbegin = 'X'.

APPEND i_bdc_table.

ENDFORM. " bdc_dynpro_start_start

FORM bdc_field USING fnam fval.

IF fval <> space.

CLEAR i_bdc_table.

i_bdc_table-fnam = fnam.

i_bdc_table-fval = fval.

APPEND i_bdc_table.

ENDIF.

ENDFORM. "bdc_insert_field