‎2013 Jun 04 12:37 PM
I am a fresher,i have to create a bdc in function module with import parameter as field.
i have declare all fields that i want in import parameter, created a internal table and passed the internal table values to recording that i have copied in source code.
1) the values i enter does not comes in internal table.
how to do this ...please help
‎2013 Jun 04 1:37 PM
Hi,
Did you create the the internal table as Tables Parameter in the FM.
Please post code.
Thanks,
Ankit.
‎2013 Jun 04 3:49 PM
‎2013 Jun 04 1:39 PM
Hi Rohan,
You created a FM and created import parametrs.
So while calling the FM are you passing the values corrrectly to the parametrs.
And you have said that you have created an internal table, where did you create that and how you are appending. can you try and explain what have you done so far?
Thanks,
Kannan N
‎2013 Jun 06 5:44 AM
i have append import parameter to internal table,and passed it to bdc.and when i execute the values does not come in xd01.
‎2013 Jun 04 1:45 PM
‎2013 Jun 04 3:52 PM
sir how to mapping is done from import parameter to internal table
‎2013 Jun 04 8:04 PM
Hi rohan gore
for uploading why are you creating FM's?
lot of conflicts in your question you need to code for mapping from import parameter to the internal table
if you don't know how to create FM in se37 see the below thread also there are lot of threads available in Google
Creating Function Modules (SAP Library - ABAP Programming (BC-ABA))
New To SAP: Creating a function module and using it [Tutorial]
Regards,
Bastin.G
‎2013 Jun 05 6:26 AM
Please post your entire source code so that we can help.
BR,
Ankit
‎2013 Jun 05 6:31 AM
FUNCTION ZXD01.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(BUKRS) LIKE RF02D-BUKRS
*" REFERENCE(VKORG) LIKE RF02D-VKORG
*" REFERENCE(VTWEG) LIKE RF02D-VTWEG
*" REFERENCE(SPART) LIKE RF02D-SPART
*" REFERENCE(KTOKD) LIKE RF02D-KTOKD
*" REFERENCE(ANRED) LIKE KNA1-ANRED
*" REFERENCE(NAME1) LIKE KNA1-NAME1
*" REFERENCE(ORT01) LIKE KNA1-ORT01
*" REFERENCE(PSTLZ) LIKE KNA1-PSTLZ
*" REFERENCE(LAND1) LIKE KNA1-LAND1
*" REFERENCE(SPRAS) LIKE KNA1-SPRAS
*" REFERENCE(AKONT) LIKE KNB1-AKONT
*" REFERENCE(ZTERM) LIKE KNB1-ZTERM
*" REFERENCE(BZIRK) LIKE KNVV-BZIRK
*" REFERENCE(KONDA) LIKE KNVV-KONDA
*" REFERENCE(ZTERM1) LIKE KNVV-ZTERM
*" REFERENCE(TAXKD) LIKE KNVI-TAXKD
*" EXPORTING
*" REFERENCE(SUBRC) LIKE SYST-SUBRC
*" TABLES
*" IT_ITAB STRUCTURE ITAB
*"----------------------------------------------------------------------
*data: bdcdata like bdcdata occurs 0 with header line.
DATA : IT_MESSAGES LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : V_MESG(50).
DATA: BEGIN OF itab OCCURS 0,
BUKRS like RF02D-BUKRS, "cOMPANY CODE
VKORG like RF02D-VKORG, "Sales Organization.
VTWEG like RF02D-VTWEG, "Distribution Channel.
SPART like RF02D-SPART, "Division
KTOKD LIKE RF02D-KTOKD, "ACCOUNT GROUP.
ANRED LIKE KNA1-ANRED, "TITLE.
NAME1 like kna1-name1, "name.
ORT01 like kna1-ort01, "city.
LAND1 like kna1-land1, "country.
SPRAS like kna1-spras, "language.
PSTLZ like kna1-pstlz, "postal code.
AKONT like knb1-akont, "Reconciliation Account in General Ledger.
ZTERM1 like knvv-zterm,
BZIRK like knvv-bzirk, "sales district.
KONDA like KNVV-KONDA, "price group.
ZTERM like knvv-zterm, "Terms of payment key.
TAXKD like KNVI-TAXKD," Tax classification for customer.
end of itab.
*perform open_group.
loop at ITAB.
perform bdc_dynpro using 'SAPMF02D' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KTOKD'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02D-BUKRS'
ITAB-BUKRS."'1100'.
perform bdc_field using 'RF02D-VKORG'
ITAB-VKORG."'1000'.
perform bdc_field using 'RF02D-VTWEG'
ITAB-VTWEG."'10'.
perform bdc_field using 'RF02D-SPART'
ITAB-SPART."'01'.
perform bdc_field using 'RF02D-KTOKD'
ITAB-KTOKD."'DEBI'.
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-ANRED'
ITAB-ANRED."'company'.
perform bdc_field using 'KNA1-NAME1'
ITAB-NAME1."'asd pvt ltd'.
perform bdc_field using 'KNA1-ORT01'
ITAB-ORT01."'pune'.
perform bdc_field using 'KNA1-PSTLZ'
ITAB-PSTLZ."'440018'.
perform bdc_field using 'KNA1-LAND1'
ITAB-LAND1."'in'.
perform bdc_field using 'KNA1-SPRAS'
ITAB-SPRAS."'en'.
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' '0360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-NAMEV(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02D' '0210'.
perform bdc_field using 'BDC_CURSOR'
'KNB1-AKONT'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNB1-AKONT'
ITAB-AKONT."'233100'.
perform bdc_dynpro using 'SAPMF02D' '0215'.
perform bdc_field using 'BDC_CURSOR'
'KNB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNB1-ZTERM'
ITAB-ZTERM1."'K000'.
perform bdc_dynpro using 'SAPMF02D' '0220'.
perform bdc_field using 'BDC_CURSOR'
'KNB5-MAHNA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02D' '0230'.
perform bdc_field using 'BDC_CURSOR'
'KNB1-VRSNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02D' '0610'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KUNNR'.
perform bdc_dynpro using 'SAPMF02D' '0310'.
perform bdc_field using 'BDC_CURSOR'
'KNVV-KONDA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNVV-BZIRK'
ITAB-BZIRK."'0002'.
perform bdc_field using 'KNVV-AWAHR'
'100'.
perform bdc_field using 'KNVV-WAERS'
'INR'.
perform bdc_field using 'KNVV-KONDA'
ITAB-KONDA."'01'.
perform bdc_field using 'KNVV-KALKS'
'1'.
perform bdc_dynpro using 'SAPMF02D' '0315'.
perform bdc_field using 'BDC_CURSOR'
'KNVV-LPRIO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNVV-KZAZU'
'X'.
perform bdc_field using 'KNVV-ANTLF'
'9'.
perform bdc_dynpro using 'SAPMF02D' '0320'.
perform bdc_field using 'BDC_CURSOR'
'KNVV-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNVV-ZTERM'
ITAB-ZTERM."'k000'.
perform bdc_dynpro using 'SAPMF02D' '1350'.
perform bdc_field using 'BDC_CURSOR'
'KNVI-TAXKD(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'KNVI-TAXKD(01)'
ITAB-TAXKD."'1'.
perform bdc_dynpro using 'SAPMF02D' '1350'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02D' '0324'.
perform bdc_field using 'BDC_CURSOR'
'KNVP-PARVW(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
*perform bdc_transaction using 'XD01'.
call transaction 'XD01'."using bdcdata mode 'A' UPDATE 'A' MESSAGES INTO IT_MESSAGES.
*perform close_group.
ENDLOOP.
***********************************
************************************
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 = V_MESG
EXCEPTIONS
NOT_FOUND = 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.
LOOP AT IT_MESSAGES WHERE MSGTYP = 'E'.
WRITE : / 'Message :'(I06) ,V_MESG.
CLEAR IT_MESSAGES.
ENDLOOP.
ENDFUNCTION.
INCLUDE BDCRECXY.
‎2013 Jun 05 7:22 AM
Hi Rohan,
Either use the TABLE parameter option in FM to get the input in the internal table
or pass the Import parameter values to the BDC subroutine without using the ITAB.
Else we shall map the data from import parameter to ITAB as shown below.
ITAB-BUKRS = BUKRS. (Import parameter)
ITAB-VKORG = VKORG.
ITAB-VTWEG = VTWEG.
........
........
........
APPEND ITAB.
Map all the field values from Import parameter to ITAB like above before looping ITAB.
Also, clarify your requirement whether it will have single set of data or multiple data.
If it is multiple data, then use TABLE parameter option in FM.
Create a structure in SE11, with the components(fields) and use it in table parameter option.
With Regards,
Gurulakshmi
‎2013 Jun 05 10:21 AM
Hi Rohan,
Please confirm your requirement as mentioned by Gurulakshmi i.e.
"Also, clarify your requirement whether it will have single set of data or multiple data."
From you code it seems that you are passing data same data as importing parameters as well as in ITAB.
Solution.
Case 1 :- Single data set ( Probablity is very less because it seems you are creating customer master)
No need to use ITAB and pass all the variable values as importing parameters in your program from where you are calling the Function ZXD01. In code instead of
perform bdc_field using 'RF02D-BUKRS'
ITAB-BUKRS. <use importing parameter>
perform bdc_field using 'RF02D-VKORG'
ITAB-VKORG. <use importing parameter>
perform bdc_field using 'RF02D-VTWEG'
ITAB-VTWEG.<use importing parameter>
Case 2 :- Multiple Data sets
No need of using Importing parameters for individual fields. Create an internal table with all the table in your calling program and in the Function module just pass the internal table in Tables parameter. Now in the FM just do the Loop at Internal Table (Which you are already doing) and it should work.
Another Issue,
In code
call transaction 'XD01'."using bdcdata mode 'A' UPDATE 'A' MESSAGES INTO IT_MESSAGES. -> Here you are collecting the messages in IT_MESSAGES table
*perform close_group.
ENDLOOP.
***********************************
************************************
Loop at IT_MESSAGES into ls_messages.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = ls_messages-MSGID
LANG = '-D'
NO = ls_messages-MSGNO
V1 = ls_messages-MSGV1
V2 = ls_messages-MSGV2
V3 = ls_messages-MSGV3
V4 = ls_messages-MSGV4
IMPORTING
MSG = V_MESG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
*-- Process all the V_MSESG which you get in every loop pass according to you rneed.
Endloop.
BR,
Ankit.
‎2013 Jun 05 12:41 PM
hi,
i have done it,
all data from fields is coming to recording field,but when transaction xd01 is executed it does not show any data.
‎2013 Jun 05 1:53 PM
Hi Rohan,
Finally got it
I hope the BDC is to create Customer.
Have you checked in display mode(Mode 'A'). Whether is there any error in recording.
Also check the recording is done until saving the data.
Because, the code in above post doesn't have the OKCODE of Save button.
Please check this once and let us know.
If all are correct, then we shall check the created customer in T.code XD02.
With Regards,
Gurulakshmi
‎2013 Jun 05 3:41 PM
yes will check nd let u now.
is their any things remaining .please tell so will do.
‎2013 Jun 04 1:48 PM
Hi Rohan,
I hope this code may help you.
Here it_comm is the internal table which contains data from excel.
Loop it_comm and passing the value from it_comm to wa_p0105(Work-area).
Later pass the fields in wa_p0105 to BDC subroutines as shown below.
LOOP AT it_comm INTO wa_comm.
* Check for Active Employee
READ TABLE it_pa0000 INTO wa_pa0000 WITH KEY pernr = wa_comm-empid.
IF sy-subrc = 0.
wa_p0105-pernr = wa_comm-empid.
wa_p0105-subty = wa_comm-subty.
lv_begda = wa_comm-begda.
wa_p0105-rep_pep_id = wa_comm-rep_pep_id.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' "to convert pernr with ALPH conversion exit format
EXPORTING
input = wa_p0105-pernr
IMPORTING
output = wa_p0105-pernr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' "to convert pernr with ALPH conversion exit format
EXPORTING
input = wa_p0105-subty
IMPORTING
output = wa_p0105-subty.
* Check for Subtype as 3 or 4
IF wa_p0105-subty = lc_subty OR wa_p0105-subty = lc_subty1.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=INS'.
PERFORM bdc_field USING 'RP50G-PERNR'
wa_p0105-pernr.
PERFORM bdc_field USING 'RP50G-TIMR6'
'X'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RP50G-SUBTY'.
PERFORM bdc_field USING 'RP50G-CHOIC'
'0105'.
PERFORM bdc_field USING 'RP50G-SUBTY'
wa_p0105-subty.
PERFORM bdc_dynpro USING 'MP010500' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0105-BEGDA'
lv_begda.
PERFORM bdc_field USING 'P0105-ENDDA'
'31.12.9999'.
PERFORM bdc_field USING 'BDC_CURSOR'
'P0105-REP_PEP_ID'.
PERFORM bdc_field USING 'P0105-REP_PEP_ID'
wa_p0105-rep_pep_id.
CALL TRANSACTION 'PA30' USING it_bdcdata MODE 'N' UPDATE 'S' MESSAGES INTO it_bdcmsg.
IF sy-subrc <> 0.
LOOP AT it_bdcmsg INTO wa_bdcmsg WHERE msgtyp = 'E'.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = wa_bdcmsg-msgid
lang = 'E'
no = wa_bdcmsg-msgnr
v1 = wa_bdcmsg-msgv1
v2 = wa_bdcmsg-msgv2
v3 = wa_bdcmsg-msgv3
v4 = wa_bdcmsg-msgv4
IMPORTING
msg = lv_return
EXCEPTIONS
not_found = 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.
ENDLOOP.
With Regards,
Gurulakshmi
‎2013 Jun 04 3:54 PM
thanks for that example,but i need input from selection screen not from excel...
‎2013 Jun 04 8:09 PM
Why don't try that yourself and post here when you are stuck somewhere. People can only help you with examples not with your actual requirement.
‎2013 Jun 05 5:58 AM
the field that i insert in import parameter are not getting into my internal table,for that what should i do,correct me if wrong...
‎2013 Jun 05 6:21 AM
Hi Rohan,
What are the inputs you are getting from the selection-screen and
what is the input to be passed to your internal table?
With Regards,
Gurulakshmi
‎2013 Jun 05 7:21 AM
i have passed this in import parameter,and i created a internal tables with this field,and passed to bdc recording that i have in sourcs code......please correct the way i am going,what else should i do..
BUKRS like RF02D-BUKRS, "cOMPANY CODE
VKORG like RF02D-VKORG, "Sales Organization.
VTWEG like RF02D-VTWEG, "Distribution Channel.
SPART like RF02D-SPART, "Division
KTOKD LIKE RF02D-KTOKD, "ACCOUNT GROUP.
--
--
--
TAXKD like KNVI-TAXKD," Tax classification for customer.
‎2013 Jun 05 7:09 AM
‎2013 Jun 05 12:55 PM
try this
1 . as per u r requirement all bdc code in one FM.
2. loop at itab into wa
call function module
here import u r wa values.
endloop.
3 . in fm source code :
use (BUKRS) VKORG) (VTWEG) instead of itab-bukrs, itab-vkorg, itab vtgew.
hope it will work , dont loop itab values within the FM
Suresh
‎2013 Jun 05 2:00 PM
‎2013 Jun 09 2:13 PM
‎2013 Jun 09 5:46 PM
This is not the place for a tutorial in basic ABAP programming. Thread locked.