Вы находитесь на странице: 1из 4

1/27/2018 BDC using CALL TRANSACTION method

Home • Trainings • Quiz • Tips • Tutorials • Functional • Cert Q's • Interview Q's • Jobs • Testimonials • Advertise • Contact Us

Custom Search
SAP Virtual/Onsite BDC using CALL TRANSACTION method
Trainings ...Previous

Now go to ABAP Editor (SE38).


Document Categories:
Enter the following code:
ABAPTM *Structure for error message
Adobe Forms
TYPES : BEGIN OF ty_s_error,
ABAP-HR
ALE & IDocs msg_err(60) TYPE c,
ALV END OF ty_s_error.
BAPI
BASIS *Input Path
BSP SELECTION-
Business Objects
Business Workflow
CRM NEW
LSMW
SAP Script/Smart Forms
BI/BW
eXchange Infrastructure (XI)
Enterprise Portals (EP)
eCATT
Object Oriented Programming
SAP Query
Userexits/BADIs
SCREEN BEGIN OF BLOCK blck WITH FRAME TITLE text-011.
WebDynpro for Java/ABAPTM
Others
PARAMETERS:
p_file TYPE rlgrap-filename, " File Path
e_file TYPE rlgrap-filename OBLIGATORY, " Error File Path
What's New? p_mode TYPE c OBLIGATORY DEFAULT 'N'. " Mode
SELECTION-SCREEN END OF BLOCK blck.
ABAP Test Cockpit HOT
* Structure Decleration
SAP ABAP Pragmas
Understanding SE32 (ABAP DATA :
Text Element Maintenance) BEGIN OF fs_field,
Creating an IDoc File on SAP bsart TYPE eban-bsart, " Document Type.
Application Server matnr TYPE eban-matnr, " Material Number.
Understanding “Advance with
dialog” option of SAP Workflow menge TYPE eban-menge, " Quantity Requested.
SAP Workflow Scenario: werks TYPE eban-werks, " Plant.
Maintenance Notification END OF fs_field.
Approval
Enhancements to a standard
class *Internal table decleration
Working with Floating Field in DATA:
Adobe Forms t_field LIKE TABLE OF fs_field,
Inserting data from Internal t_bdcdata LIKE TABLE OF bdcdata.
Table into the step “Send Mail”
Display GL Account long text
using enhancement framework DATA:
Differences between fs_bdcdata LIKE LINE OF t_bdcdata, " Structure type of bdcdata
polymorphism in JAVA and w_str TYPE string.
ABAP
Passing multiline parameters
from an ABAP Class event to a * Data decleration
Workflow container DATA:
Concept of Re-evaluate agents wa_path TYPE string ,
for active work items in SAP
Workflow wa_error TYPE string,
Dynamic creation of component wa_cnt TYPE i,
usage in ABAP WebDynpro w_mode TYPE c,
Adobe Forms: Display symbols wa_cnt1(2) TYPE n,
like copyright and others
it_output type table of ty_s_error,
Deactivate Hold functionality in
Purchase order (ME21N) wa_output like line of it_output.
Quiz on OOABAP
Add fields in FBL5N using AT SELECTION-SCREEN.
BADIs * Mode 'A' = Foreground mode
Tutorial on Wide casting
* Mode 'N' = Background mode
Defining a Range in Module
Pool Program IF p_mode = 'A' OR p_mode = 'N' .
Copy fields from one
structure/table into another w_mode = p_mode.
structure/table
Side Panel Usage in NWBC
ELSE.
*Error Message
Contribute? MESSAGE 'PLEASE ENTER THE MODE A or N' TYPE 'E'.
ENDIF.

Sample Specs * Opening window for path selection


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
What's Hot? EXPORTING
program_name = syst-cprog
Web Dynpro for ABAP Tutorials dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
Join the Mailing List
file_name = p_file.

http://saptechnical.com/Tutorials/ABAP/BDC/CallTransaction2.htm 1/4
1/27/2018 BDC using CALL TRANSACTION method
Enter name and email address below:
Name: TYPES:
fs_struct(4096) TYPE c OCCURS 0 .
Email:
DATA:
w_struct TYPE fs_struct.
Subscribe Unsubscribe
GO
* Uploading excel file.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
* I_LINE_HEADER =
i_tab_raw_data = w_struct
i_filename = p_file
TABLES
i_tab_converted_data = t_field
EXCEPTIONS
conversion_failed = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

*Opening window for Error file download


AT SELECTION-SCREEN ON VALUE-REQUEST FOR e_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = e_file.

* start of selection event.


START-OF-SELECTION.

LOOP AT t_field INTO fs_field .


REFRESH: t_bdcdata.
CLEAR fs_bdcdata.
PERFORM populate_bdcdata.
PERFORM insert_data.
ENDLOOP. " LOOP AT it_c.

*********************(populate_bdcdata)***********************
* part 1
FORM populate_bdcdata.
PERFORM :
fill_bdc_data USING 'SAPMM06B' '0100' 'X' ' ' ' ',
fill_bdc_data USING '' '' '' 'EBAN-BSART' fs_field-
bsart, " Document Type.
fill_bdc_data USING '' '' '' 'BDC_OKCODE' '/00', " Enter.

fill_bdc_data USING 'SAPMM06B' '0106' 'X' ' ' ' ',


fill_bdc_data USING '' '' '' 'EBAN-MATNR(01)' fs_field-
matnr, " Material Number.
fill_bdc_data USING '' '' '' 'EBAN-MENGE(01)' fs_field-
menge, " Quantity Requested.
fill_bdc_data USING '' '' '' 'EBAN-WERKS(01)' fs_field-werks, " Plant.
fill_bdc_data USING '' '' '' 'BDC_OKCODE' '/00', " Enter.

fill_bdc_data USING 'SAPMM06B' '0102' 'X' '' '' ,


fill_bdc_data USING '' '' '' 'BDC_OKCODE' '=BU'. " Save.

ENDFORM. " Form populate_bdc.

* part 2
FORM fill_bdc_data USING value(p_program)
value(p_dynpro)
value(p_dynbegin)
value(p_fnam)
value(p_fval).
CLEAR fs_bdcdata .
IF p_dynbegin = 'X' .
fs_bdcdata-program = p_program .
fs_bdcdata-dynpro = p_dynpro .
fs_bdcdata-dynbegin = p_dynbegin .
APPEND fs_bdcdata TO t_bdcdata.
ELSE.
fs_bdcdata-fnam = p_fnam.
fs_bdcdata-fval = p_fval.
CONDENSE fs_bdcdata-fval.
APPEND fs_bdcdata TO t_bdcdata.
ENDIF. " IF p_dynbeg..

ENDFORM . " Fill_entry

*********************(insert_data)****************************
FORM insert_data.

http://saptechnical.com/Tutorials/ABAP/BDC/CallTransaction2.htm 2/4
1/27/2018 BDC using CALL TRANSACTION method
*Data decleration for Error Message
DATA:
t_msg TYPE TABLE OF bdcmsgcoll, " Collecting Error messages
w_msg TYPE bdcmsgcoll,
w_msg1(51).

* Call transaction 'ME51'


CALL TRANSACTION 'ME51' USING t_bdcdata
MODE w_mode
UPDATE 'S'
MESSAGES INTO t_msg.

IF sy-subrc EQ 0.
* Uploaded into the database
WRITE :/ 'DATA UPLOADED IN TABLE EBAN...' .
ELSE.
* Error Found
LOOP AT t_msg INTO w_msg WHERE msgtyp EQ 'E'.
* Format Message
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = w_msg-msgid
msgnr = w_msg-msgnr
msgv1 = w_msg-msgv1
msgv2 = w_msg-msgv2
msgv3 = w_msg-msgv3
msgv4 = w_msg-msgv4
IMPORTING
message_text_output = w_msg1.

wa_output-msg_err = w_msg1.

*Error message in downloaded file


data:
wa_string(10) type c.

wa_string = fs_field-matnr.

concatenate wa_string wa_output-msg_err into wa_output-


msg_err separated by space.

APPEND wa_output-msg_err TO it_output.

wa_error = e_file.

CALL FUNCTION 'GUI_DOWNLOAD'


EXPORTING
* BIN_FILESIZE =
filename = wa_error
* FILETYPE = 'ASC'
* APPEND = ' '
write_field_separator = 'X'
TABLES
data_tab = it_output
*
.
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.

ENDLOOP.

ENDIF.

ENDFORM. "insert_data

Run the Program.

Enter the path of file you need to upload.

And then enter the path of a file where error log will be created.

Finally select the mode. We have following option for the mode.

1. A = Foreground (Step by step processing will be done by you)

2. N = Background (All the Processing will be done in Background)

http://saptechnical.com/Tutorials/ABAP/BDC/CallTransaction2.htm 3/4
1/27/2018 BDC using CALL TRANSACTION method
3. E = Display Error ( If there is any error, it will be displayed in log otherwise it is similar to
background mode)

Finally when all the data is uploaded .

In case of Error in the upload of any data, an Error file gets generated at the above given path.

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM


Home • Contribute • About Us • Privacy • Terms Of Use • Disclaimer • Safe • Companies: Advertise on SAPTechnical.COM | Post Job • Contact Us
©2006-2007 SAPTechnical.COM. All rights reserved.
All product names are trademarks of their respective companies. SAPTechnical.COM is in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver, and and any other SAP trademarks are registered trademarks of SAP AG in Germany and in several other countries.
Every effort is made to ensure content integrity. Use information on this site at your own risk.

Graphic Design by Round the Bend Wizards

http://saptechnical.com/Tutorials/ABAP/BDC/CallTransaction2.htm 4/4

Вам также может понравиться