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

reg: BDC Recording

Former Member
0 Likes
1,097

hi friends...

In BDC recording methods.

i want to know how to transfer data from presentation server to database server.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
969

hi,

u can transfer data from presentation server to db by recording .in this sap provides both SESSION and CALL TRANSACTION logic.

first go to SHDB TCODE select NEW RECORDING ->SPECIFY NAME AND TCODE ->enter manditory fields ->save->back->select ur recording->select PROGRAM option in the tool bar->specify attributes->save->click source code option->control leads to se38.almost 70% logic is provided by sap.

u have to declare ur internal table and u have to upload ur data using GUI_UPLOAD to ur internal table.

after executing u can select either session or calltransaction method for uploading dataif u select session u have to go to SM35 TCODE to process the session.

CHECK BELOW CODING u can able to do recording .

report zpxd01

no standard page heading line-size 255.

data:begin of itab occurs 0,

kunnr like rf02d-kunnr,

land1 like kna1-land1,

spras like kna1-spras,

end of itab.

data:bdcdata like bdcdata occurs 0 with header line,

MESTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

include bdcrecx1.

start-of-selection.

call function 'GUI_UPLOAD'

exporting

filename = 'C:\Documents and Settings\srip\Desktop\xyz.txt'

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 = VIRUS_SCAN_PROFILE

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH = FILELENGTH

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

perform open_group.

loop at itab.

perform bdc_dynpro using 'SAPMF02D' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02D-KUNNR'

itab-kunnr.

perform bdc_dynpro using 'SAPMF02D' '7100'.

perform bdc_field using 'RF02D-KTOKD'

'ZAG2'.

perform bdc_dynpro using 'SAPMF02D' '0110'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-SPRAS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNA1-LAND1'

itab-land1.

perform bdc_field using 'KNA1-SPRAS'

itab-spras.

perform bdc_dynpro using 'SAPMF02D' '0120'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-LIFNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02D' '0125'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-NIELS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02D' '0130'.

perform bdc_field using 'BDC_CURSOR'

'KNBK-BANKS(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02D' '0340'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02D' '0370'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'KNA1-CIVVE'

'X'.

perform bdc_dynpro using 'SAPMF02D' '0360'.

perform bdc_field using 'BDC_CURSOR'

'KNVK-NAMEV(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_transaction using 'XD01' MODE 'A' UPDATE 'A' MESSAGES INTO MESTAB..

endloop.

perform close_group.

hi friends...

In BDC recording methods.

i want to know how to transfer data from presentation server to database server.

7 REPLIES 7
Read only

abdul_hakim
Active Contributor
0 Likes
969

Hi

You need to first upload ur data into internal table using GUI_UPLOAD.

Cheers,

Hakim

Read only

Bema
Active Participant
0 Likes
969

Hi,

You can use GUI_UPLOAD to upload file from presentation server to internal tables.

Then you can use this internal table to update it in SAP tables in the PERFORM

stmts.

Regards,

Beena

Read only

Former Member
0 Likes
969

sorry my question is,

i want to transfer data from presentation server to database server in recording method?

Read only

Former Member
0 Likes
969

You can use the transaction CG3Z to move the file on the presentation server to the application server.

Regards,

Ravi

Read only

Former Member
0 Likes
969

Hi Selva,

Plese find below an example program which will get the CSV file from application server and updates the file.

&----


*& Report ZBCBRNL_UPDATE_QUERY_FILES *

*& *

&----


& Program Name : ZBCBRNL_UPDATE_QUERY_FILES &

& Module Name : Basis &

& Sub-Module : Common across BASIS &

& Author : Sunil Yarlagadda &

& Create Date : 07/09/2006 &

& DER Number : CR06235 &

& Program Type : Report &

& SAP Release : 4.7 &

& Transport Nr. : &

& Description :Updation of CSV files generated by the BW queries&

&----


&

& REVISION LOG &

& &

& LOG# DATE AUTHOR DER DESCRIPTION &

& R000 07/09/06 SunilY CR06235 Initial Implementation &

&----


REPORT zbcbrnl_update_query_files .

----


  • Declaration.

----


TYPES: BEGIN OF ty_table,

record(1000),

END OF ty_table.

TYPES: BEGIN OF ty_dir,

string(50),

END OF ty_dir.

DATA: t_table TYPE STANDARD TABLE OF ty_table,

t_dir TYPE STANDARD TABLE OF ty_dir.

DATA: x_table TYPE ty_table,

x_dir TYPE ty_dir.

DATA: g_count(10) TYPE n,

g_index TYPE i,

g_header(1000) TYPE c,

g_footer(1000) TYPE c,

g_msg(100) TYPE c,

g_path TYPE rlgrap-filename,

g_file(15) TYPE c.

CONSTANTS: c_x TYPE c VALUE 'X',

c_sep TYPE c VALUE '/'.

----


  • Selection screen

----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS : sel1 RADIOBUTTON GROUP rad DEFAULT 'X' USER-COMMAND u1.

PARAMETERS: p_path1 TYPE rlgrap-filename MODIF ID co1 DEFAULT

'/GFS/NL/Application_development/R/Outbound/Data/NL_ENG_REV'.

SELECTION-SCREEN SKIP 1.

PARAMETERS : sel2 RADIOBUTTON GROUP rad.

PARAMETER : p_path2 TYPE rlgrap-filename MODIF ID co2 DEFAULT

'/GFS/NL/Application_development/R/Outbound/Data/NL_ENG_PROF'.

SELECTION-SCREEN END OF BLOCK b1.

----


  • Selection screen output

----


AT SELECTION-SCREEN OUTPUT.

  • Set the attributes of radiobuttons dynamically.

PERFORM sub_radiobutton_validation.

----


  • Selection screen on value request

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path1.

  • F4 help for parameter path1.

PERFORM sub_path_f4 USING p_path1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path2.

  • F4 help for parameter path1.

PERFORM sub_path_f4 USING p_path2.

----


  • Start of selection

----


START-OF-SELECTION.

  • Set the selected file path.

PERFORM sub_file_path.

  • Read the file from apllication server

PERFORM sub_read_file.

IF NOT t_table[] IS INITIAL.

  • Add the header and footer information to the internal table.

PERFORM sub_add_header_footer.

  • Write the internal table to application server with the same name.

PERFORM sub_write_file.

ENDIF.

&----


*& Form sub_radiobutton_validation

&----


  • Radiobuttons Validation

----


FORM sub_radiobutton_validation .

IF sel1 = c_x.

LOOP AT SCREEN.

IF screen-group1 = 'CO1'.

screen-intensified = 1.

screen-input = 1.

ELSEIF screen-group1 = 'CO2'.

screen-intensified = 0.

screen-input = 0.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

ELSEIF sel2 = c_x.

LOOP AT SCREEN.

IF screen-group1 = 'CO1'.

screen-intensified = 0.

screen-input = 0.

ELSEIF screen-group1 = 'CO2'.

screen-intensified = 1.

screen-input = 1.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

ENDIF.

ENDFORM. " sub_radiobutton_validation

&----


*& Form sub_path_f4

&----


  • F4 help for the path

----


FORM sub_path_f4 USING p_p_path1.

CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'

IMPORTING

serverfile = p_p_path1

EXCEPTIONS

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

ENDFORM. " sub_path_f4

&----


*& Form sub_file_path

&----


  • Get the path of the file based on the selction screen

----


FORM sub_file_path .

IF sel1 EQ c_x.

g_path = p_path1.

ELSE.

g_path = p_path2.

ENDIF.

ENDFORM. " sub_file_path

&----


*& Form sub_read_file

&----


  • Read the file from the give path

----


FORM sub_read_file .

DATA: l_row(2) TYPE n,

l_date TYPE datum,

l_sysid TYPE sysid.

  • Open file in application server for reading

OPEN DATASET g_path FOR INPUT

MESSAGE g_msg

IN TEXT MODE

ENCODING DEFAULT.

IF sy-subrc NE 0.

WRITE:/ g_msg.

STOP.

ELSE.

  • Read the file from application server into internal table.

DO.

READ DATASET g_path INTO x_table.

IF sy-subrc NE 0.

IF sy-index EQ 1.

WRITE:/ 'No records found in the file.'(004).

STOP.

ENDIF.

EXIT.

ELSE.

IF sy-index EQ 1.

l_row = x_table+0(2).

l_date = x_table+3(8).

l_sysid = x_table+12(3).

IF l_row EQ '00' AND

l_sysid EQ sy-sysid.

WRITE:/ 'File is already updated on'(002),l_date.

STOP.

ENDIF.

ENDIF.

APPEND x_table TO t_table.

CLEAR x_table.

ENDIF.

ENDDO.

ENDIF.

  • Getting the file name from path.

SPLIT g_path AT c_sep INTO TABLE t_dir.

DESCRIBE TABLE t_dir LINES g_index.

READ TABLE t_dir INTO x_dir INDEX g_index.

IF sy-subrc EQ 0.

g_file = x_dir.

ENDIF.

  • Close the file.

CLOSE DATASET g_path.

ENDFORM. " sub_read_file

&----


*& Form sub_add_header_footer

&----


  • Add header and footer to the internal table

----


FORM sub_add_header_footer .

  • Get the number of records in the internal table

DESCRIBE TABLE t_table LINES g_count.

  • Delete the leading zeros.

SHIFT g_count LEFT DELETING LEADING '0'.

  • Prepare header and footer information that needs to insert

  • into the file in application server.

CONCATENATE: '00' sy-datum sy-sysid INTO g_header

SEPARATED BY space,

'99' g_count INTO g_footer

SEPARATED BY space.

  • prepare the footer index

g_count = g_count + 2.

  • Insert header and footer into the internal table.

INSERT: g_header INTO t_table INDEX 1,

g_footer INTO t_table INDEX g_count.

ENDFORM. " sub_add_header_footer

&----


*& Form sub_write_file

&----


  • Write the file to the application server with the same name

----


FORM sub_write_file .

  • Open file in application server for writing.

OPEN DATASET g_path FOR OUTPUT

MESSAGE g_msg

IN TEXT MODE

ENCODING DEFAULT.

IF sy-subrc NE 0.

WRITE:/ g_msg.

STOP.

ELSE.

  • Write the file into the application server with the same name.

LOOP AT t_table INTO x_table.

TRANSFER x_table TO g_path.

ENDLOOP.

WRITE:/ g_file,'File is successfully updated'(003).

ENDIF.

  • Close the file.

CLOSE DATASET g_path.

ENDFORM. " sub_write_file

Regards,

Sunil

Read only

Former Member
0 Likes
970

hi,

u can transfer data from presentation server to db by recording .in this sap provides both SESSION and CALL TRANSACTION logic.

first go to SHDB TCODE select NEW RECORDING ->SPECIFY NAME AND TCODE ->enter manditory fields ->save->back->select ur recording->select PROGRAM option in the tool bar->specify attributes->save->click source code option->control leads to se38.almost 70% logic is provided by sap.

u have to declare ur internal table and u have to upload ur data using GUI_UPLOAD to ur internal table.

after executing u can select either session or calltransaction method for uploading dataif u select session u have to go to SM35 TCODE to process the session.

CHECK BELOW CODING u can able to do recording .

report zpxd01

no standard page heading line-size 255.

data:begin of itab occurs 0,

kunnr like rf02d-kunnr,

land1 like kna1-land1,

spras like kna1-spras,

end of itab.

data:bdcdata like bdcdata occurs 0 with header line,

MESTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

include bdcrecx1.

start-of-selection.

call function 'GUI_UPLOAD'

exporting

filename = 'C:\Documents and Settings\srip\Desktop\xyz.txt'

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 = VIRUS_SCAN_PROFILE

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH = FILELENGTH

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

perform open_group.

loop at itab.

perform bdc_dynpro using 'SAPMF02D' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02D-KUNNR'

itab-kunnr.

perform bdc_dynpro using 'SAPMF02D' '7100'.

perform bdc_field using 'RF02D-KTOKD'

'ZAG2'.

perform bdc_dynpro using 'SAPMF02D' '0110'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-SPRAS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNA1-LAND1'

itab-land1.

perform bdc_field using 'KNA1-SPRAS'

itab-spras.

perform bdc_dynpro using 'SAPMF02D' '0120'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-LIFNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02D' '0125'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-NIELS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02D' '0130'.

perform bdc_field using 'BDC_CURSOR'

'KNBK-BANKS(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02D' '0340'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02D' '0370'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'KNA1-CIVVE'

'X'.

perform bdc_dynpro using 'SAPMF02D' '0360'.

perform bdc_field using 'BDC_CURSOR'

'KNVK-NAMEV(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_transaction using 'XD01' MODE 'A' UPDATE 'A' MESSAGES INTO MESTAB..

endloop.

perform close_group.

Read only

Former Member
0 Likes
969

Hi selva,

Useful Steps For You

Following are the steps for bdc using recroding method

1. enter 'SHDB' transaction

2.click 'New Recording'

3. Fill recording name , transaction name and click on start recording .

4. enter one samle data in the new screen for the transaction displayed.

5.Go back to scrren of 'shdb' by clicking on back button.

6.select recording and click Program Tab

7.Enter prgram name nad neccesary details.

and u get the program prepared by sap for u

8.then use that proagram name in SE38 transaction

9.create internal table to read the data from text fiel in presenation server.

10.Perform open_group and close_group.

11.loop at iternal table which is filled by GUI_Upload.

and assign fileds of internal table to program fileds in the loop.

U r done with the BDC recording

Regards.

note: Reward if useful