Application Development 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: 

How to load data to SAP CRM using BAPI?????

Former Member
0 Kudos
1,037

Hi all,

I have a question and I am struck. In my new job, client is doing a conversion programs using BAPI. The scenario is like this, they have a flat file which is in MS access and we have to load that data into SAP CRM using the BAPI's called by the ABAP programs..

Can anyone help me on this, give me some information on this process. Also if possible, can you show me a pointer which has information about this type of scenarios.

I will apprecaite your support and will give appropirate points.

Regards,

-Ash

1 ACCEPTED SOLUTION

Former Member
0 Kudos
439

What sort of data do you need to upload to CRM? Are the conversion programs SAP programs or custom?

Rob

11 REPLIES 11

FredericGirod
Active Contributor
0 Kudos
439

Hi Ashok,

you have to find the good bapi to use, have a look to the url : http://ifr.sap.com

You will find all the information to use with you BAPI.

To find the link between the BAPI name & the function name, look the transaction BAPI.

Good luck

Frédéric

Former Member
0 Kudos
440

What sort of data do you need to upload to CRM? Are the conversion programs SAP programs or custom?

Rob

0 Kudos
439

Hi Rob,

The conversion programs which the client is using are ABAP progrms such as Z programs.

So, if we use the BAPI, it will ask for the field mappings between the source structures with that of the target structures???

Appreciate your answers...Waiting for the reply.

Regards,

-Ash

0 Kudos
439

But what kind of data are you loading? Based on that, you will have to determine which BAPIs to use and then figure out the mapping.

Rob

0 Kudos
439

Hi Rob,

We are using Accounts Master, Contact Masters and Oppurtunities to the SAP CRM system. Let me know, if you can help me further??

Thanks,

Asho

0 Kudos
439

For accounts, try BAPI_ACCASSIGNMENT_LOADDATA; for contacts, try BAPI_BUPR_CONTP_CREATE. Don't know about opportunities. Check the documentation on how to use them in your implementation.

Rob

Former Member
0 Kudos
439

Hi Ashok,

If you trying to upload business transactions, you can write a plain BDC program to format the data into table of structure CRMXIF_BUSTRANS and call function module CRMXIF_ORDER_SAVE. Above function could be used for any of the following data upload - Lead, opportunity, quotation, contract, Sales order etc.

Hope this helps!

Former Member
0 Kudos
439

Use Transaction BAPI to look for an appropriate BAPI function module or in SE 37 use BAPI_object name.

Object name can be Material, Vendor etc.

Once you find an appropriate BAPI function module all you need to do is read data into Internal table(s) and map the fields to the BAPI structure fields and call the BAPI.

Some BAPIs have an X structure these allow us to check (X) any field that we may want to update in SAP and uncheck any field that we may not want to update.

BAPIS create an object if it does not exist already or change an object if it exists already.

BAPI's do not commit data so after a successful call (or for every 1000 successful calls or so) do a commit using BAPI_TRANSACTION_COMMIT. (_ROLLBACK is available too).

<b>Example.</b>

BAPI_MATERIAL_SAVEDATA is a function module used for creating one Material at a time. There is another, BAPI_MATERIAL_SAVEREPLICA for creating several Materials at a time.

It has a structure for HEADERDATA where industry sector and Material type and material number are entered along with View selection.

And it has one structure or table each for every Material Master table, like MARA, MARC , MBEW etc.

Former Member
0 Kudos
439

Hi,

There is a transaction code for the Initial download of the data from R/3 to CRM. I.e.

R3AS

Reward me if it helps you.

regards,

Sampath

0 Kudos
439

Hi Sampath,

With this Transaction, can we load the data from flat file which is in MS SQL2000 database to the CRM using the BAPI. I mean, if this transaction loads the data from the DB, then there is no need to writing ABAP programs using the BAPI. Let me know about it. I still have lot of doubts as I am going through the functional and technical documents.

Regards,

-Ash

Former Member
0 Kudos
439

I've a simmilar requirement , where i've to load the data from text file. I've wriiten a program in SAP CRM , but it does not save the sales order. please tell me whast the error, i've hardcoded the values,

i want to load the data using bapi. Please suggest

&----


*& Report Z_SALESORDER_CREATE2 *

*& *

&----


*& *

*& *

&----


REPORT z_salesorder_create2.

DATA wa_crmxif_bustrans_t TYPE crmxif_bustrans_t.

DATA wa_crmxif_bustrans TYPE crmxif_bustrans.

DATA wa_crmxif_orgman TYPE crmxif_orgman.

DATA: wa_crmxif_item TYPE crmxif_bustrans_item.

.

DATA: wa_crmxif_status TYPE crmxif_status,

itab_status LIKE TABLE OF wa_crmxif_status.

DATA: wa_bapiretm TYPE bapiretm,

wa_bapireti TYPE bapireti .

DATA: wa_bapiretc TYPE bapiretc.

DATA: wa_partner TYPE crmxif_partner,

itab_partner LIKE TABLE OF wa_partner.

DATA: BEGIN OF wa_temp_partner,

partner_no(10) TYPE c,

partner_fct(8) TYPE c,

partner_pft(4) TYPE c,

pft_subtype(4) TYPE c,

END OF wa_temp_partner,

itab LIKE TABLE OF wa_temp_partner.

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

  • FILLING THE STRUCTURE OF THE ORDER HEADER *

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

*wa_crmxif_bustrans-object_task = 'B'.

wa_crmxif_bustrans-process_type = 'YOR1'.

wa_crmxif_bustrans-object_type = 'BUS2000115'.

wa_crmxif_bustrans-posting_date = sy-datum.

wa_crmxif_bustrans-descr_language = 'E'.

wa_crmxif_bustrans-created_at = 20070718203200.

wa_crmxif_bustrans-created_by = 'SIDHESHS'.

wa_crmxif_bustrans-scenario = ' A A'.

wa_crmxif_bustrans-logical_system = 'CRDCLNT220'.

wa_crmxif_bustrans-crm_release = 'BBPCRM 400'.

wa_crmxif_bustrans-client = 220.

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

  • END FILLING THE STRUCTURE OF THE ORDER HEADER *

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

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

  • FILLING THE STRUCTURE OF THE ITEM *

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

wa_crmxif_item-item_number = '00010'.

wa_crmxif_item-product_id = '300000020'.

*WA_CRMXIF_ITEM-QUANTITY = '10'.

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

  • END FILLING THE STRUCTURE OF THE ITEM *

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

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

  • FILLING THE STRUCTURE OF THE PARTNER *

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

wa_temp_partner-partner_no = '2000000060'.

wa_temp_partner-partner_fct = '00000001'.

wa_temp_partner-partner_pft = '0001'.

wa_temp_partner-pft_subtype = 'CRM '.

APPEND wa_temp_partner TO itab.

*wa_temp_partner-partner_no = '2000000060'.

*wa_temp_partner-partner_fct = '00000002'.

*wa_temp_partner-partner_pft = '0002'.

*wa_temp_partner-pft_subtype = 'CRM '.

*APPEND wa_temp_partner TO itab.

*

*wa_temp_partner-partner_no = '2000000060'.

*wa_temp_partner-partner_fct = '00000003'.

*wa_temp_partner-partner_pft = '0003'.

*wa_temp_partner-pft_subtype = 'CRM '.

*APPEND wa_temp_partner TO itab.

*

*wa_temp_partner-partner_no = '2000000060'.

*wa_temp_partner-partner_fct = '00000004'.

*wa_temp_partner-partner_pft = '0004'.

*wa_temp_partner-pft_subtype = 'CRM '.

*APPEND wa_temp_partner TO itab.

*

*wa_temp_partner-partner_no = '2000000060'.

*wa_temp_partner-partner_fct = '00000005'.

*wa_temp_partner-partner_pft = '0005'.

*wa_temp_partner-pft_subtype = 'CRM '.

*APPEND wa_temp_partner TO itab.

LOOP AT itab INTO wa_temp_partner.

MOVE-CORRESPONDING wa_temp_partner TO wa_partner.

APPEND wa_partner TO itab_partner.

ENDLOOP.

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

  • END FILLING THE STRUCTURE OF THE PARTNER *

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

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

          • FILLING THE STRUCTURE OF THE ORGMAN *

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

****WA_CRMXIF_ORGMAN-SALES_ORG = '0103'.

****WA_CRMXIF_ORGMAN-SALES_ORG_RESP = '0103'.

****WA_CRMXIF_ORGMAN-DIS_CHANNEL = '01.

****WA_CRMXIF_ORGMAN-DIVISION = '00

****

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

          • END FILLING THE STRUCTURE OF THE ORGMAN *

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

****

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

          • FILLING THE STRUCTURE OF STATUS *

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

****WA_CRMXIF_STATUS-STATUS = ' '.

****WA_CRMXIF_STATUS-ACTIVE = ' '.

****WA_CRMXIF_STATUS-TXT04 = ' '.

****WA_CRMXIF_STATUS-TXT30 = ' '.

****

****APPEND WA_CRMXIF_STATUS TO ITAB_STATUS.

****

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

          • END FILLING THE STRUCTURE OF THE STATUS *

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

****

*MOVE WA_CRMXIF_ORGMAN TO WA_CRMXIF_BUSTRANS-ORGDATA-DATA.

*MOVE ITAB_STATUS TO WA_CRMXIF_BUSTRANS-STATUS-DATA.

MOVE itab_partner TO wa_crmxif_bustrans-partner-data.

APPEND wa_crmxif_item TO wa_crmxif_bustrans-item.

APPEND wa_crmxif_bustrans TO wa_crmxif_bustrans_t.

CALL FUNCTION 'CRMXIF_ORDER_SAVE'

EXPORTING

data = wa_crmxif_bustrans_t

IMPORTING

return = wa_bapiretm.

write : 'save ', / sy-subrc.

IF sy-subrc = 0.

COMMIT WORK .

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

WRITE 'SALES ORDER CREATED SUCCESSFULLY'.

ELSE.

WRITE: 'SY-SUBRC =', sy-subrc.

ENDIF.

LOOP AT wa_bapiretm INTO wa_bapireti.

LOOP AT wa_bapireti-object_msg INTO wa_bapiretc.

WRITE: / wa_bapiretc-message , wa_bapiretc-type,wa_bapiretc-number.

WRITE: / wa_bapiretc-message_v1,wa_bapiretc-message_v2.

ENDLOOP.

ENDLOOP.