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

BDC's

Former Member
0 Likes
810

Hi all,

I have a doubt on BDC's.While creating flat file for transaction mm02 for that i want to change some values and some values should be remain same for that iam taking forward slash (/)in flat file but the value has to be displayed while selecting screens for this i need to write a code how? can any one please help me.

Hi all,

I have a doubt on BDC's.While creating flat file for transaction mm02 for that i want to change some values and some values should be remain same for that iam taking forward slash (/)in flat file but the value has to be displayed while selecting screens for this i need to write a code how? can any one please help me.

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
747

First, you should not be using BDC for transaction MM02, please use BAPI BAPI_MATERIAL_SAVEDATA to update the material master.

If a value from your file contains a '/' you will simple, not fill the value in from your source file.

Here is a sample program which uses the BAPI.

This program updates the "old material number" field on the basic data view.

report zrich_0003 .

data: headdata type bapimathead.
data: clientdata type bapi_mara.
data: clientdatax type bapi_marax.
data: return type  bapiret2 .
data: returnm type table of bapi_matreturn2 with header line.
data: xmara type mara.

parameters: p_matnr type mara-matnr.

select single * from mara into xmara
          where matnr = p_matnr.

headdata-material        = xmara-matnr.
headdata-ind_sector      = xmara-mbrsh.
headdata-matl_type       = xmara-mtart.
headdata-basic_view = 'X'.

clientdata-old_mat_no = 'THE TEXT'.
clientdatax-old_mat_no = 'X'.


call function 'BAPI_MATERIAL_SAVEDATA'
  exporting
    headdata                   = headdata
    clientdata                 = clientdata
    clientdatax                = clientdatax
*   PLANTDATA                  =
*   PLANTDATAX                 =
*   FORECASTPARAMETERS         =
*   FORECASTPARAMETERSX        =
*   PLANNINGDATA               =
*   PLANNINGDATAX              =
*   STORAGELOCATIONDATA        =
*   STORAGELOCATIONDATAX       =
*   VALUATIONDATA              =
*   VALUATIONDATAX             =
*   WAREHOUSENUMBERDATA        =
*   WAREHOUSENUMBERDATAX       =
*   SALESDATA                  =
*   SALESDATAX                 =
*   STORAGETYPEDATA            =
*   STORAGETYPEDATAX           =
 importing
   return                     = return
  tables
*   MATERIALDESCRIPTION        =
*   UNITSOFMEASURE             =
*   UNITSOFMEASUREX            =
*   INTERNATIONALARTNOS        =
*   MATERIALLONGTEXT           =
*   TAXCLASSIFICATIONS         =
    returnmessages             = returnm
*   PRTDATA                    =
*   PRTDATAX                   =
*   EXTENSIONIN                =
*   EXTENSIONINX               =
          .

check sy-subrc  = 0.

Please remember to award points for helpful answers and mark your posts as solved when solved completely. Thanks.

REgards,

Rich Heilman

Read only

Former Member
0 Likes
747

While recording MM02 just place the cursor on those fields which are being changed. Do not touch the other fields. And while populating the BDC Structure, use those fields which are to be changed.

In this way u can have your chosen fields can be edited.

Read only

Former Member
0 Likes
747

Hi saripalli,

1. some values should be remain same

For that u have to write / use some pre-defined

logic.

2. Out of 15 fields (for eg.)

field number 4, 9, 13, 15 have to be same (for 1st record),

field number 1, 5, 11 have to be same (for 2nd record),

and so on..

3. How will the system come to know about that ?

4. For this u can pre-define some format that

if the field needs to be same,

then the field (in the txt file)

should contain blank(nothing)

OR should contain a pre-defined character,

eg. / or @ or # or anything...

5. Now in your program,

u will have to SPECIFICALLY CHECK

this PRE-DEFINED VALUE

. Only if it is SOMETHING OTHER THEN THIS VALUE (/ # BLANK ETC)

ONLY THEN,

assign the value to the bdc field,

other wise do not assign anything.

6. this way u will achive what u want.

regards,

amit m.

Read only

Former Member
0 Likes
747

If your incoming file contains / in the records then we can replace the / in the data with space and populate those fields only for which u have value.

TRANSLATE gt_records USING '/'.

before appending the data to the internal table of type bdcdata just check if the value is intial or not .

if not initial ,just append that particular record into that internal table else ignore the record.

Hope this solves your problem.

Thanks and Regards ,

Sriranjani Chimakurthy.