Currency problem in BAPI_MATERIAL_SAVEDATA while uploading valuation class

Hello Experts,
I am uploading valuation class using BAPI_MATERIAL_SAVEDATA.
While uploading it is showing runtime error "Unable to interpret KG as a number".
I have used the FM CONVERSION_EXIT_CUNIT_INPUT to convert the UOM from the file to Field symbol.
still the same. please guide me.
I have pasted my code below.
Kindly go through and help would be highly appreciated.
*& Report  ZPRI_MAT_PRICE_UPLOAD
REPORT  ZPRI_MAT_PRICE_UPLOAD no standard page heading line-size 150.
tables : mbew,      " Material valuation
         makt,      " Material description
         mara.      " General material master
data : begin of t_matvclass occurs 0,
       material type matnr,     " Material
       ind_sec type mbrsh,      " Industry sector
       mat_typ type mtart,      " Material type
       val_class type BKLAS,    " Valuation class
       MOV_PR TYPE VERPR,       " MOVING PRISE
       STD_PR TYPE STPRS,       " STANDARD PRISE
       base_uom like mara-meins,     " Material unit
       mat_desc type maktx,     " Material description - MAKTX
       plant type werks,        " Plant
       langu(2),
       end of t_matvclass.
data : wa like line of t_matvclass.
data: begin of it_makt occurs 0.
      include structure bapi_makt.
      data end of it_makt.
data :bapi_head like bapimathead,     " Header Segment with Control Info
      bapi_clientdata like bapi_mara,    " Material Data at Client Level
      bapi_clientdatax like bapi_marax,  "Checkbox Structure
      bapi_valclass like BAPI_MBEW,      " Valuation class
      bapi_valclassx like BAPI_MBEWX,    " Checkbox Structure
*      BAPI_MOVING_PR LIKE BAPI_MBEW,     "MOVING PRISE
*      BAPI_MOVING_PRX LIKE BAPI_MBEWX,   "MOVING PRISE
*      BAPI_STD_PRISE LIKE BAPI_MBEW,     "STANDARD PRISE
*      BAPI_STD_PRISEX LIKE BAPI_MBEWX,   "STANDARD PRISE
      bapi_return like bapiret2,         " Bapi return structrue
      returnm type table of bapi_matreturn2 with header line.
data : it_excel type alsmex_tabline occurs 0 with header line.
data: begin of it_ret occurs 0.
       include structure bapiret2.
      data end of it_ret.
* Data objects for exception handling.
data : lv_converr type ref to CX_SY_CONVERSION_ERROR,
       lv_dynerr type ref to CX_SY_DYN_CALL_ERROR.
data : txt_converr type string,
       txt_converr_l type string,
       txt_dynerr type string,
       txt_dynerr_l type string.
data : char_uom(4) type c.    " Global UOM after conversion
* Declaring selection screen for selecting a data file
* for uploading valuation class
selection-screen begin of block b1 with frame title text-001.
parameter : file_nam type rlgrap-filename obligatory default
              'C:\master data UPDATED_test.xls'.
parameter : p_begcol type i default 1,        " no-display,
            p_begrow type i default 2,        "   no-display,
            p_endcol type i default 9,        " no-display,
            p_endrow type i default 267.      " no-display.
*parameters: p_valare type mbew-bwkey obligatory.    " Valuation area
selection-screen end of block b1.
at selection-screen on value-request for file_nam.
perform F_get_file using file_nam.
start-of-selection.
perform F_xls_itab using file_nam changing it_excel.
perform F_move_data.
*perform F_get_data.
perform F_Display_data.
*&      Form  F_xls_itab
*       text
*      -->P_FILE_NAM  text
*      <--P_IT_EXCEL  text
form F_xls_itab  using    p_file_nam changing p_it_excel.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    filename                      = file_nam
    i_begin_col                   = p_begcol
    i_begin_row                   = p_begrow
    i_end_col                     = p_endcol
    i_end_row                     = p_endrow
  tables
    intern                        = it_excel
EXCEPTIONS
   INCONSISTENT_PARAMETERS       = 1
   UPLOAD_OLE                    = 2
   OTHERS                        = 3.
endform.                    " F_xls_itab
*&      Form  F_get_file
*     Subroutine to get the file on F4
*      -->P_FILE_NAM  text
form F_get_file  using    p_file_nam.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
   PROGRAM_NAME        = SYST-REPID
   DYNPRO_NUMBER       = SYST-DYNNR
*   FIELD_NAME          = ' '
*   STATIC              = ' '
*   MASK                = ' '
  CHANGING
    file_name           = file_nam
EXCEPTIONS
   MASK_TOO_LONG       = 1
   OTHERS              = 2.
endform.                    " F_get_file
*&      Form  F_Display_data
*       text
*  -->  p1        text
*  <--  p2        text
form F_Display_data .
skip 2.
*write:/2 'Valuation area :', p_valare.
*write:/2 'Standard price :', p_stdprc.
skip 2.
  write:/29 sy-uline(120).
  write:/29 sy-vline,
         30 'Material' color 1,               " Material - MATNR
         50 sy-vline, 'Ind_sector' color 1,   " Industry sector  - MBRSH
         62 sy-vline, 'Mat_typ' color 1,   " Material type - MTART
         75 sy-vline, 'Valuation class' color 1,  " Valuation class
         85 sy-vline, 'Base UOM' color 1,          " Base UOM
         95 sy-vline, 'Material Decp' color 1,     " Material descp
         120 sy-vline, 'Mov Price',                 " Moving price
         130 sy-vline, 'Std Price',                 " Standard price
         140 sy-vline, 'Plant',                     " Plant
         150 sy-vline.
  write:/29 sy-uline(120).
loop at t_matvclass into wa.
  write:/29 sy-vline,
         30 wa-material color 2,               " Material - MATNR
         50 sy-vline,
         55 wa-ind_sec color 2 right-justified, " Industry sector
         62 sy-vline,
         66 wa-mat_typ color 2,                " Material type - MTART
         75 sy-vline,
         78 wa-val_class color 2 right-justified, " Valuation class
         85 sy-vline,
         88 wa-base_uom color 2 right-justified,  " Base UOM
         95 sy-vline,
         98 wa-mat_desc color 2 left-justified,  " Material Desc
         120 sy-vline, wa-MOV_PR,                 " Standard price
         130 sy-vline, wa-STD_PR,                 " Moving price
         140 sy-vline, wa-plant,                     " Plant
         150 sy-vline.
endloop.
write:/29 sy-uline(64).
endform.                    " F_Display_data
*&      Form  F_move_data
*      Subroutine to move data from excel to internal table
*  -->  p1        text
*  <--  p2        text
form F_move_data .
data : lv_index type i.
field-symbols <fs>.
* Sorting the internal table
sort it_excel by row col.
clear it_excel.
loop at it_excel.
  move it_excel-col to lv_index.
* Assigning each record to the internal table row.
  assign component lv_index of structure wa to <fs>.
* Assigning the field value to a field symbol
if lv_index eq 5.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
  EXPORTING
    INPUT                = it_excel-value
   LANGUAGE             = SY-LANGU
IMPORTING
   OUTPUT               = char_uom.
** Moving the converted UOM to  field symbol
move char_uom to <fs>.
else.
   move it_excel-value to <fs>.
endif.
  at end of row.
  append wa to t_matvclass.
  clear wa.
  endat.
endloop.
endform.                    " F_move_data
*&      Form  F_get_data
*       text
*  -->  p1        text
*  <--  p2        text
form F_get_data .
loop at t_matvclass into wa.
try.
* BAPIHEAD --- > Header Segment with Control Information
bapi_head-material = wa-material.
bapi_head-ind_sector = wa-ind_sec.
bapi_head-matl_type = wa-mat_typ.
bapi_head-account_view = 'X'.
* For Clien Data
bapi_clientdata-BASE_UOM = wa-base_uom.
bapi_clientdatax-base_uom = 'X'.
bapi_clientdatax-base_uom_iso = 'X'.
* For Valuation Class.
bapi_valclass-val_area = wa-plant.
bapi_valclass-val_class = wa-val_class.
bapi_valclass-std_price = wa-STD_PR.
bapi_valclass-MOVING_PR = wa-MOV_PR.
* For Valuation Class control checkbox.
bapi_valclassx-val_area = wa-plant.
bapi_valclassx-val_class = 'X'.
bapi_valclassx-std_price = 'X'.
bapi_valclass-MOVING_PR = 'X'.
refresh it_makt.
wa-langu = SY-LANGU.
it_makt-langu = wa-langu.
it_makt-matl_desc = wa-mat_desc.
append it_makt.
clear it_ret.
refresh it_ret.
if t_matvclass[] is initial.
  write:/ 'Cannot be updated'.
else.
perform F_call_bapi.
endif.
catch CX_SY_CONVERSION_ERROR into lv_converr.
   txt_converr = lv_converr->get_text( ).
   txt_converr_l = lv_converr->get_longtext( ).
   write:/ 'Error:', txt_converr color 5.
   write:/ 'Error:', txt_converr_l color 3.
endtry.
endloop.
endform.                    " F_get_data
*&      Form  F_bapi_commit
*       text
*  -->  p1        text
*  <--  p2        text
form F_bapi_commit.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
*   WAIT          =
* IMPORTING
*   RETURN        =
if sy-subrc eq 0.
  write:/2 ' Transaction commited' color 4.
else.
  write:/2 'Unable to commit the transaction' color 4.
endif.
endform.                    " F_bapi_commit
*&      Form  F_call_bapi
*       text
*  -->  p1        text
*  <--  p2        text
form F_call_bapi .
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
  EXPORTING
    headdata                  = bapi_head
    CLIENTDATA                 = bapi_clientdata
    CLIENTDATAX                = bapi_clientdatax
    VALUATIONDATA              = bapi_valclass
    VALUATIONDATAX             = bapi_valclassx
IMPORTING
   RETURN                     = it_ret
TABLES
   MATERIALDESCRIPTION        =  it_makt
   RETURNMESSAGES        =  returnm.
   IF it_ret-type eq 'E' or it_ret-TYPE eq 'S'.
     Write:/1 it_ret-type,
            8 it_ret-id,
            30 it_ret-number,
            38 it_ret-message,
            190 it_ret-parameter,
            210 it_ret-row,
            220 it_ret-field.
   endif.
endform.                    " F_call_bapi
Regards,
Ranjith N

resloved.
issue with the internal table structrue.

Similar Messages

  • Regarding bdc(views problem in mm01 while uploading the data)

    hi experts,
    i have coded a bdc in which i m using mm01 and extending the material to the different plant ,but here in some cases depending upon the material the views get changed for solving this i have to deselect and again select the views which i want and also i have to provide the valuation type for this material, so plz suggest me how to rectifie the views problem.......

    Ravi,
      Do one thing.Develop some temporary BDC programs for different material  with required views.
    Finally develop a final program.In that internal table loop ,put case statement on material
    when 'mat1'  .
        take the relevant code from above temporary progarms and copy here.
    when '2'.
    endcase.
    At last delete all temporary programs.
    Hope your problem will get solved
    Don't forget to reward if useful.

  • Error in Valuation class for a material

    Dear Friends,
    While assigning Valuation class for a material, system is throwing an error message " Enter the valuation class for the previous period/year".
    Please give me a solution.
    Thanks in advance.
    Bye,
    Varun Siddharth

    Dear All,
    My problem is solved.
    Thank you all once again.
    Bye,
    Varun Siddharth

  • Problems in Material Master Upload by LSMW

    Dear Experts,
    The question was asked to me in interview, What Problems you face while uploading your material master data by LSMW ?
    Please give me some information on this question.
    Thanks in Advance

    hi,
    Check the link it would be usefull:
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/c5/213c487a3c11d3bc8100105a6588b2/frameset.htm
    Hope it helps...
    Regards
    Priyanka.P

  • Problem with project stock valuation class

    Dear All,
    We have an issue regarding the Revenue Inventory and Capital Inventory. There is a certain balance amount which should be in capital but system is showing in Revenue and vice versa.
    The reason for this is that when the material was created, in some materials the main valuation class was 3032(Project) and in some it was maintained as 3030(revenue). But project stock valuation class was not maintained.
    Now the problem persists in the G/L balances, the G/L of project stock (132006)displays some amount of revenue(132000) and vice versa.
    We tried to maintain the project stock valuation class (3032) for materials for which the main valuation class is 3030 (Revenue),but still the G/L for revenue (132000) is getting hit.
    At the end, the requirement is that G/L for revenue (132000) should hit when revenue procurement is there and G/L for capital (132006) should hit when capital procurement is there.
    Kindly suggest the way forward.
    Regards,
    Harsh

    Thanks Venkat, we have thought of the same as a last stop but there are hundreds of materials which has this problem and there would be many open documents for them.
    If anything could be suggested other then this, and I wanted clarification on one more point that the materials for which main valuation class was 3030 and later we added 3032 in project stk Val class but after maintaining it. When we procure(Capital procurement), it is still showing the balance in G/L 132000(Revenue).
    Regards,
    Harsh

  • Long text problem while uploading Inspection plan through BDC.

    Hi,
    I am facing some problem while uploading the inspection plan. There are few MICs for which we are having long text, while uploading the inspection plan through BDC - some other long text is getting copied into the MIC's long text. After checking I came to know that in function module, read_text - some text which is stored in ABAP memory is getting copied into the inspection plan.
    I am working in SAP release 4.7. I have checked with SAP notes: 97419, but it is also not satisfying.
    Waiting for quick solution.
    Thanks in advance.
    Fahié

    Hi a®s,
    Thanks a lot for your kind reply.
    My requirement is I want to maintain long text for few MICs (which are not having long texts at MIC level) in inspection plan (QP01).
    When I am trying to manually assign the MIC's to inspection plan (QP01), long text is copied whereas I am not clicking the long text icon in (QP01). Long text is not maintained in MIC level, still some long text is copied to this MIC. This was also happening while uploading the inspection plan thro' BDC.
    I believe what you have mentioned about function module SAVE_TEXT cannot be used here since long text is already copied before we pass the long text. Also if we pass some long text, still apart from the long text what we have passed there is some other long text copied (extra long text).
    Waiting for quick solution.
    Thanks in advance.
    Fahié

  • Problem while uploading data from flat file

    hi friends,
    suppose if there are 100 records in flat file , if 20 records uploaded with out any problem and if error occurs while uploading remaing data . is necessary to upload entire data again or else only remaining data should be uploaded?
    i had used call transaction for purchase order application?
    please give me reply  soon its urgent
    thanks & regards
    priya

    Hi Hari,
    you have to upload the remaining data.
    as u have used CT method, do 1 thing trap the error data in runtime & prepare another flat file. next time correct the data in new flat file. & run the DBC program again with this new flat file.
    Reward if useful
    Regards
    ANUPAM

  • I have problem with cn22 transaction while uploading

    dear Experts
    i  have problem while uploading the data into the CN22 transaction
    i t is updating frontend  mode 'A' but not updating with backend  when  'N'
    please tell me the solution.
    perform bdc_dynpro      using 'SAPLCOKO' '2000'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'CAUFVD-AUFNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=LIST'.
    perform bdc_field       using 'CAUFVD-AUFNR'
                                  wa_data-aufnr.
    perform bdc_dynpro      using 'SAPLCOVG' '2000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=EINF'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'AFVGD-VORNR(01)'.
    perform bdc_field       using 'RC27X-FLG_SEL(01)'
                                   FLG_SEL_01_002.
    perform bdc_dynpro      using 'SAPLCOVG' '2000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'AFVGD-ARBPL(01)'.
    perform bdc_field       using 'AFVGD-VORNR(01)'
                                   wa_data-vornr.
    perform bdc_field       using 'AFVGD-LTXA1(01)'
                                  wa_data-ltxa1.
    perform bdc_field       using 'AFVGD-DAUNO(01)'
                                  wa_data-dauno.
    perform bdc_field       using 'AFVGD-ARBPL(01)'
                                  wa_data-arbpl.
    perform bdc_dynpro      using 'SAPLCOVG' '2000'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VSNETEXT-NPLNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    *perform bdc_transaction using 'CN22'.
    call transaction 'CN22' using it_bdcdata
    OPTIONS FROM wa_CTU_PARAMS
    messages into mess_tab.

    Hi,
    First check the messages in intenal table mess_tab in debugging mode with mode N.
    Recording looks ok.
    Regards
    Praveen

  • Problem while uploading bank details in Vendor Master - XK01

    Hello Experts,
    I am encountering a problem while uploading Vebndor Master Details in Quality server . The bank details for a given bank (Eg : BankABC and Bank Key IN) throws an error saying BANK IN BANKABC DOES NOT EXIST . But , with the same details i am able to upload in Sandbox and Development Servers. Pls suggest on the same.

    Hello again,
    Thank you for the inputs.
    Venkat,
    All the required fields are active. Please give some more input.
    Rob,
    Bank is supposed to be created during the upload. The bank details which already exists in the sytem are not throwing the error. Please give suggestions for this scenario.
    Regards,
    Trishna

  • Problem while uploading data with GUI UPLOAD Function

    Hi,
      I am facing problem while uploading data with FM GUI UPLOAD    in out text file there are 7 row  but after the FM GUI UPLOAD  there are 14 entries are coming in Internal table   and each alternate row is coming as blank  with  0000 in some column   in internal table first row is proper and second line is blank so on.
    what can be the problem .
    The program in which we are using this we are using it from last 2 year but we are facing problem today only.
    regards,
      zafar

    Hi,
      The file formate is same as it is from last two years it is automatically generated by one another bar code server and there is no change  in the file formate.
      So waht can be the problem  to check any inconsistancy in system  i have develop a samll program fro  uploading a text file with same function module ,  but it is working fine.
    regards,
      zafar

  • Problem occuring while uploading the template therough BAPI

    Hi,
    I'm uploading inspection plans template through BAPI. While uploading its giving a error message like invalid file type. I'm using Excel sheet. I tried through Text format also. Same error message i'm getting.
    Can anybody help me.
    Regards,
    Narendra

    I guess your reply relates to a custom transaction code, if it is so, then it wont help much.
    You would need to paste the program code, as this is a custom program which resides in your SAP system & not a std. transaction which can be accessed in any SAP system.
    Regards,
    Vivek

  • Problems while uploading Task List - Service Pack with LSMW

    We are trying to upload General Maintenance Task List using LSMW. We are using Standard Batch/Direct Input method with Object 0490.
    We need to upload task list header, operations, maintenance pack, component and service pack for operations.
    We have created separate files containing data for different structures and they are linked using Group, group counter and operation number according below
    Header
    |----Operations
    .......... |----Long Text
    ..........|----Maintenance Pack
    ..........|----Components
    ..........|----Service Pack
    We have multiple operations per task list and multiple services per operation. The service pack is required only for a specific control key - PM03.  As per the configuration this screen (PROGRAM - SPLMLSP, Screen Number - 0200) is accessible only when the value PM03 is entered in the operation. We are able to upload all other details except service pack details. We have tried using structure IBIPBDCD for the same.
    While uploading the task list in foreground, when control key is entered as PM03 in an operation, service pack screen is displayed with error u201CNo batch input data for screen SAPLMLSP 0200u201D. The data provided in structure IBIPBDCD does not get processed at this time.
    On exiting the screen using back button, the data in IBIPBDCD structure is passed incorrectly to fields in screen 3400 (SAPLCPDI)
    Are we doing something incorrect? Is there a way to use this standard functionality to upload task lists with service packs?
    Thanks
    Edited by: jvalitp on Dec 15, 2011 12:46 PM

    Hi,
    When loading the tasklists you need to define a source structure as per the IBIP structure. You have different levels for example level 1 - header then below that level 2 - Operations, Header Long text then below that you have level 3 - Operation Long text, Operation Package assignments, operation component allocation.
    For each of these levels you need an identifier that links then together. In your source file specify identifier 1 for header, Identifier 1 and Identifier 2 for operations, identifier 1 identifier 2 and identifier 3 for packages. This way the system can create the correct structure when it reads the data from the text file.
    The identifiers are numeric and will dissapear once the files are loaded. specify then in the source structure as 2 characters and remember to set the xcel file up to have a 2 character field.
    For the header file each line will be a new identifier 1,2,3,etc.
    The operations are assigned to the header and have 2 identifiers. The first corresponds to the header identifier the next is a sequential number stating at 1 and incrementing for each line e.g Header 1 op 1, header 1 op 2, header 2 op 3, header 2 op 4, header 2 op 5 (this would be 2 header records. The first with 2 operations on it the second with 3 operations)
    The package is assigned to the operation and as such needs to have a third identifier. Header (identifier 1), Operation (identifier 2), Package (identifier 3) Example Header 1 op 1 pack 1, header 1 op 2 pack 2, header 2 op 3 pack 3, header 2 op 4 pack 4, header 2 op 5 pack 5
    I have a loading file for each of the items i.e. Header file, Operation file, maintenance package file. This is then assigned to the respective source structure.
    Regards,
    ravi

  • Problem while uploading FF_5

    Hello,
    We are uploading the bank file using FF_5. when we upload the file the file is getting uploaded but showing error message difference is to large for clearing. When we check in FEBA the items in files are displayes as TO BE POSTED.
    Can any one let me know the reason of the error.
    BR,
    Zulfikar

    Hi,
    Thanks for your response on this.
    In my text file korean language is there....but while uploading this text file containing korean language properly formatted in the tcode ff.5 then it is not recoginising that text and also the format of the data is changing...
    PLz suggest on that...
    Regards,
    Rohan.

  • Having problem while uploading the data.

    Hi All,
    i am facing some problem when trying to upload csv file in the database.
    ERROR:
    "SQL*Loader-704: Internal error: ulconnect: OCIServerAttach [0]
    ORA-12560: TNS:protocol adapter error".
    have anybody aware of this kind of problem or having knowledge regarding this problem.database is working fine.
    -rajnish

    Hi,
    About this error, you need to enable tracing and get the exact error from the listener trace files:
    12560, 00000, "TNS:protocol adapter error"
    // *Cause: A generic protocol adapter error occurred.
    // *Action: Check addresses used for proper protocol specification. Before
    // reporting this error, look at the error stack and check for lower level
    // transport errors.For further details, turn on tracing and reexecute the
    // operation. Turn off tracing when the operation is complete.Regards,
    Yoann.

  • De-linking (Valuation class & GL A/c) automatic posting in Invoice booking

    Experts,
    I have a issue regarding link between FI & MM
    From what I understand,
    there is a link between Service & Valuation class
    & also a link between valuation class & GL.
    This link enables automatic FI line item posting while invoice booking.
    My question:
    1. Can we break the linkage between valuation class & GL i.e. we want to stop the automatic posting
    2. What is the effect of above
    3. Would you advise to do this .. ? Why?
    Regards,
    KPS007

    Hi,
    SAP standard process are the best business practises and it should changed only when we have genuine business problem and not for people issue.
    There are several scenarios will occur during MIGO and MIRO. For each scenario system should determine a correct Inventory account, GR/IR clearing account, Price difference account and etc. First you need to prepare an excel sheet with all your possible business scenario, valuation area/valuation grouping code and their respective GL accounts. Once you have listed out all the scenarios and correct GL accounts, you can configure the system as per your requirement. Initial home work is needed to avoid any difference in account posting. Hence try to fix the source of your problem rather than changing the best practise. Account determination is vast and it cannot be explained here but please refer the below link.
    http://help.sap.com/saphelp_46c/helpdata/en/12/1a39516e36d1118b3f0060b03ca329/content.htm
    Regards,
    Senthil

Maybe you are looking for