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

CALL TRANSACTION AND SESSION METHODS PROGRAM NEEDED FOR XK01 TRANSACTION

Former Member
0 Likes
699

Hi experts,

i am new to bdc, my task is to write a program for call transaction as well as session method for the transaction xk01,i kindly request you to send me the program code for the following requirement.

<<removed_by_moderator>>

thanx

Edited by: Vijay Babu Dudla on Feb 23, 2009 9:32 AM

Hi experts,

i am new to bdc, my task is to write a program for call transaction as well as session method for the transaction xk01,i kindly request you to send me the program code for the following requirement.

<<removed_by_moderator>>

thanx

Edited by: Vijay Babu Dudla on Feb 23, 2009 9:32 AM

3 REPLIES 3
Read only

Former Member
0 Likes
668

hello,

check this link.

http://sap.niraj.tripod dot com/

Thank u,

santhosh

Read only

0 Likes
668

Hello

check this report which have both call transaction and session mothods are used.

report XXX

data:it_bdctab like bdcdata occurs 0 with header line,

it_mestab like bdcmsgcoll occurs 0 with header line.

data: begin of itab occurs 0,

matnr like mara-matnr,

mbrsh like mara-mbrsh,

mtart like mara-mtart,

maktx like makt-maktx,

meins like mara-meins,

end of itab.

data: begin of it_success occurs 0 ,

matnr like mara-matnr,

end of it_success.

data: begin of it_error occurs 0,

lineno type i,

message type string,

end of it_error.

data: v_rec_count type i,

v_error type i,

v_success type i,

v_index type sy-tabix,

v_flag type c.

selection-screen begin of block b1 with frame title text-001.

parameters: p_path type rlgrap-filename,

p_trans radiobutton group gr default 'X',

p_sess radiobutton group gr.

selection-screen end of block b1.

at selection-screen on value-request for p_path.

perform get_file_path.

start-of-selection.

perform upload_file.

perform build_bdc.

if p_sess = 'x'.

perform session_method.

elseif p_trans = 'x'.

*----


submit data to Call transaction.

perform call_transaction.

endif.

form get_file_path .

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = ' '

importing

file_name = p_path.

.

endform. " Get_file_path

form upload_file .

data:file_name type string.

file_name = p_path.

call function 'GUI_UPLOAD'

exporting

filename = file_name

filetype = 'ASC'

has_field_separator = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

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

endform. " Upload_file

form build_bdc .

perform fill_bdc using : 'X' 'SAPLMGMM' '0060',

' ' 'BDC_OKCODE' '=AUSW',

' ' 'RMMG1-MATNR' 'itab-matnr',

' ' 'RMMG1-MBRSH' 'itab-mbrsh',

' ' 'RMMG1-MTART' 'itab-mtart',

'X' 'SAPLMGMM' '0070',

' ' 'BDC_OKCODE' '=ENTR',

'X' 'SAPLMGMM' '4004',

' ' 'BDC_OKCODE' '=BU',

' ' 'MAKT-MAKTX' 'itab-maktx',

' ' 'MARA-MEINS' 'itab-meins'.

endform. " build_bdc

form fill_bdc using p_flag p_name p_value . "value(p_0165)

"value(p_0166)

"value(p_0167).

if p_flag = 'X'.

it_bdctab-program = p_name.

it_bdctab-dynpro = p_value.

it_bdctab-dynbegin = p_flag.

append it_bdctab.

elseif not p_value is initial.

it_bdctab-fnam = p_name.

it_bdctab-fval = p_value.

append it_bdctab.

endif.

endform. " fill_bdc

form call_transaction .

call transaction 'mm01' using it_bdctab

mode 'n'

update 's'

messages into it_mestab.

if sy-subrc = 0 .

read table it_mestab with key msgtyp = 'S'.

if sy-subrc = 0.

it_success-matnr = it_mestab-msgv1.

append it_success.

v_success = v_success + 1.

endif.

else .

read table it_mestab with key msgtyp = 'E'.

if sy-subrc = 0.

call function 'FORMAT_MESSAGE'

exporting

id = sy-msgid

lang = '-D'

no = sy-msgno

v1 = sy-msgv1

v2 = sy-msgv2

v3 = sy-msgv3

v4 = sy-msgv4

importing

msg = it_error-message

exceptions

not_found = 1

others = 0

.

if sy-subrc <> 0.

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

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

endif.

it_error-lineno = v_index.

append it_error.

v_error = v_error + 1.

endif.

endif.

endform. " call_transaction

form session_method .

if p_sess = 'X'.

call function 'BDC_OPEN_GROUP'

exporting

client = sy-mandt

group = 'SREEVANI'

  • HOLDDATE = FILLER8

keep = 'X'

user = sy-uname.

endif.

call function 'BDC_INSERT'

exporting

tcode = 'mm01'

tables

dynprotab = it_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.

endif.

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. " session_method

Thank u,

santhosh

Read only

Former Member
0 Likes
668

Hi,

Its easy.

1, Goto Transaction SHDB.

2, Click on New Recording

3, Give your Recording a Name

4, Provide the Transaction below it XK01 and press enter

5, fill in all fields that you think has to be filled in

6, save the vendor.

7, now save the Recording and click on Back.

8, Select the recording you have done.

9, Click on Create Porgram

10, Select from recording and give all the details it asks for and save it.

Now you have to make some small changes like Using Gui Upload if your file is in front end or depending on your requirement.

Remove defaulted values which you'll find in performs and setit with the proper fields.

Activate it and execute you'll get both you asked for.

Thanks,

Prashanth