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

BDC in Background

Former Member
0 Likes
597

Hi All,

I have written the following BDC program, which is running fine in foreground mode.

I want to run same BDC in Background mode. What r the changes i have to do. i heardthat i have to use JOB_open, Job_submit & Job_close .Where i have to call them in my code ?

Pls help me..

REPORT ZMM01_BDC .

include bdcrecx1.

parameters: filename like rlgrap-filename.

types: begin of record,

MBRSH(1),

MTART(4),

MAKTX(40),

MEINS(3),

end of record.

*internal table declaration.

data: itab_program type standard table of record,

wa_itab type record.

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

  • At Selection Screen

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

*at selection-screen on value-request for filename.

  • perform query_filename changing filename.

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

*START-OF-SELECTION

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

start-of-selection.

*-- Upload flat data to ITAB.

perform upload_to_itab.

*{ chg001 -- modified as per requirement

perform open_group.

loop at itab_program into wa_itab.

perform upload_programs.

endloop.

perform close_group.

----


  • FORM UPLOAD_TO_ITAB *

----


  • ........ *

----


form upload_to_itab.

data: pfile type string.

clear pfile.

move filename to pfile.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD

EXPORTING

FILENAME = 'C:\Documents and Settings\Administrator\Desktop\r'

  • FILETYPE = 'asc'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = 'X'

  • CODEPAGE = SPACE

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • VIRUS_SCAN_PROFILE =

  • IMPORTING

  • FILELENGTH =

  • HEADER =

CHANGING

DATA_TAB = itab_program[].

  • 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

  • NOT_SUPPORTED_BY_GUI = 17

  • ERROR_NO_GUI = 18

  • others = 19

*IF SY-SUBRC <> 0.

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

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

*ENDIF.

if sy-subrc <> 0.

write : 'File opening error'.

endif.

endform.

----


  • FORM QUERY_FILENAME *

----


  • ........ *

----


  • --> P_FILENAME *

----


form query_filename changing p_filename.

data : tmp_filename like filename.

call function 'WS_FILENAME_GET'

exporting

def_filename = filename

mask = ',.txt,.txt.'

mode = 'O'

title = 'Select the file to Upload'

importing

filename = tmp_filename

exceptions

inv_winsys = 01

no_batch = 02

selection_cancel = 03

selection_error = 04.

if sy-subrc = 0.

filename = tmp_filename.

endif.

endform.

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

*perform open_group.

&----


*& Form UPLOAD_programs

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form upload_programs.

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MTART'.

perform bdc_field using 'BDC_OKCODE'

'=AUSW'.

perform bdc_field using 'RMMG1-MBRSH'

wa_itab-MBRSH.

perform bdc_field using 'RMMG1-MTART'

wa_itab-MTART.

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 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

wa_itab-MAKTX.

perform bdc_field using 'MARA-MEINS'

wa_itab-MEINS.

perform bdc_field using 'MARA-MTPOS_MARA'

'NORM'.

perform bdc_transaction using 'MM01'.

endform.

Flat File data:

C fert created by rh3 kg

P halb created by hr3 kg

Thanks in advance

Krupali..

Hi KR,

Sorry ,, No sample code avaialble as of now...

Regards,

Naveen

4 REPLIES 4
Read only

Former Member
0 Likes
556

Hi,

Apart from the Fm what u have said...,

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD will only work in the foreground and not in the background.

If u want to run the same in the back ground, then the file shud be in Application server, and u have to use DATASET concept.

Revrt back if any issues.

regards,

Naveen

Read only

0 Likes
556

HI Naveen,

If You any sample code, pls send it to me.So that i make changes.

Thanks

Krupali.

Read only

0 Likes
556

Hi KR,

Sorry ,, No sample code avaialble as of now...

Regards,

Naveen

Read only

Former Member
0 Likes
556

from presentation server u first transfer the data to application server...then run the same upload prog...( job open...job submit...job close).