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

import parameter in internal tables

Pratik_Ingawale
Participant
0 Likes
4,570

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

25 REPLIES 25
Read only

Former Member
0 Likes
3,377

Hi,

Did you create the the internal table as Tables Parameter in the FM.

Please post code.

Thanks,

Ankit.

Read only

0 Likes
3,377

no ,how to do that....tell in steps please

Read only

Former Member
0 Likes
3,377

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

Read only

0 Likes
3,377

i have append import parameter to internal table,and passed it to bdc.and when i execute the values does not come in xd01.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,377

There is no reason those values would "magically" pass from import parameters to the internal table, you have to code the mapping from import parameter to the internal table yourself, or did I misunderstand you, and why did you create an internal table ?

Regards,

Raymond

Read only

0 Likes
3,377

sir how to mapping is done from import parameter to internal table

Read only

0 Likes
3,377

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

Read only

0 Likes
3,377

Please post your entire source code so that we can help.

BR,

Ankit

Read only

0 Likes
3,377

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.

Read only

0 Likes
3,377

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

Read only

0 Likes
3,377

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.

Read only

0 Likes
3,377

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.

Read only

0 Likes
3,377

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

Read only

0 Likes
3,377

yes will check nd let u now.

is their any things remaining .please tell so will do.

Read only

Former Member
0 Likes
3,377

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

Read only

0 Likes
3,377

thanks for that example,but i need input from selection screen not from excel...

Read only

0 Likes
3,377

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.

Read only

0 Likes
3,377

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

Read only

0 Likes
3,377

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

Read only

0 Likes
3,377

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.

Read only

Pratik_Ingawale
Participant
0 Likes
3,377

Please tell me the way i should do.

Read only

former_member198834
Participant
0 Likes
3,377

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

Read only

0 Likes
3,377

whats the  2 point ...loop at.....

Read only

0 Likes
3,377

please explain with an example...

Read only

matt
Active Contributor
0 Likes
3,377

This is not the place for a tutorial in basic ABAP programming. Thread locked.