ABAP function module to check data is a valid number

Hi Guys,
I am parsing a long string from a R3 table to load into BW, and need to verify the incoming data is valid number instead of having some or all charactors so I can load into a quantity field, in BW, it is a Key figure infoObject. The string length is 14.
For example, if data is 123.34, then the number is valid. If data is 1A23, then it is not valid number.
Thanks in advance.
JA

Hi,
SAP provides the function BUS_NUMBERFIELD_PAI,
You pass in a table/field reference that matches the number you want to match to say GLT0-TSLVT (len 15 dec 2) and the string.
It tells you if the number is valid and will even return a reformatted string.
I.E.
123456,78 is valid and formatted as 123,456.99
123,,456.78 raises AMOUNT_NOT_ALLOWED
123.456 raises INTERNAL_ERROR as there are too many decimals
Hope that helps.
FUNCTION BUS_NUMBERFIELD_PAI .
*"  IMPORTING
*"     VALUE(I_TABNAME) LIKE  DD03L-TABNAME (Ex
*"     VALUE(I_FIELDNAME) LIKE  DD03L-FIELDNAME
*"     VALUE(I_CURRENCY) LIKE  TCURC-WAERS OPTIONAL
*"  EXPORTING
*"     VALUE(E_VALUE_DB)
*"  CHANGING
*"     VALUE(C_VALUE_DYNP)
*"  EXCEPTIONS
*"      NUMBER_NOT_ALLOWED
*"      AMOUNT_NOT_ALLOWED
*"      INTERNAL_ERROR

Similar Messages

  • Crystal Reports for VS2010 using a custom SAP ABAP function module data source

    I recently worked with Crystal Reports 2011 and was able to connect and retrieve data from our R/3 system via an ABAP function module. While researching other features, I found this version that can be installed into Visual Studio 2010. The parameters are not very user friendly in Crystal Reports so I was hoping to create a custom dialog to collect my report parameters.
    Does anyone know if I were to install Crystal Reports for Visual Studio 2010, would I be able to design a front-end selection screen in a Visual Basic form and then pass the input to through the Crystal Reports connection to my ABAP function module to retrieve the data filtered on the back-end by the selection screen parameters and return the results to be reported in the Crystal Reports output?
    I am using Visual Studio 2010 Professional Visual Basic with the .NET Framework 4.0 on 32-bit Windows 7. I was able to connect to our R/3 system in Crystal Reports 2011, so if I were to install Crystal Reports for VS2010, would there be a similar way of connecting to SAP?
    Any assistance or direction would be greatly appreciated.
    Thanks,
    Bryan

    Hello Bryan
    I don't know for sure, but I doubt this will work in CRVS2010. Only hope is that the utility available for download in this KBA will point you in the right direction.
    - Ludek
    Follow us on Twitter
    Got Enhancement ideas? Try the SAP Idea Place
    Share Your Knowledge in SCN Topic Spaces

  • ABAP Function Module Example to move data from one Cube into Another

    Hi experts,
    Can any please help out in this ..?
    A Simple ABAP Function Module Example to move data from one Cube into Another Cube
    (How do i send the data from one client to another client using Function moduel).
    Thanks
    -Upen.
    Moderator message: too vague, help not possible, please describe problems in all technical detail when posting again, BI related? ("cube"), also search for information before asking.
    Edited by: Thomas Zloch on Oct 29, 2010 1:19 PM

    This is the start routine to duplicate records in two currencies.
    DATA: datew   TYPE /bi0/oidateto,
          datew2  TYPE rsgeneral-chavl,
          fweek   TYPE rsgeneral-chavl,
          prodhier TYPE /bi0/oiprod_hier,
          market  TYPE /bic/oima_seg,
          segment TYPE /bic/oizsegment.
    DATA: BEGIN OF S_DATA_PACK OCCURS 0.
            INCLUDE STRUCTURE /BIC/CS8ZSDREV.
    DATA: END OF S_DATA_PACK.
    S_DATA_PACK[] = DATA_PACKAGE[].
      REFRESH DATA_PACKAGE.
      LOOP AT S_DATA_PACK.
        move-corresponding s_data_pack to DATA_PACKAGE.
        if DATA_PACKAGE-loc_currcy = 'EUR'.
          DATA_PACKAGE-netval_inv = DATA_PACKAGE-/bic/zsdvalgrc.
          DATA_PACKAGE-CURRENCY = 'USD'.
          APPEND DATA_PACKAGE.
          DATA_PACKAGE-netval_inv = DATA_PACKAGE-/bic/zsdvalloc.
          DATA_PACKAGE-CURRENCY = 'EUR'.
          APPEND DATA_PACKAGE.
        else.
          DATA_PACKAGE-netval_inv = DATA_PACKAGE-/bic/zsdvalgrc.
          DATA_PACKAGE-CURRENCY = 'USD'.
          APPEND DATA_PACKAGE.
        endif.
      ENDLOOP.
    This is to load Quantity field
    RESULT = COMM_STRUCTURE-BILL_QTY.
    This is to load Value field
    RESULT = COMM_STRUCTURE-NETVAL_INV.
    UNIT = COMM_STRUCTURE-currency.

  • Function module to check if a given file/folder path is valid or not?

    Hi,
    I am using function modules GUI_DOWNLOAD and GUI_UPLOAD.
    Is there any function module to check if a given file/folder path is valid or not?
    Thanks.

    Hi Kumar ,
    REPORT  zdir_test.
    TYPE-POOLS: abap.
    DATA: v_dir TYPE string.
    DATA: v_bol TYPE abap_bool.
    v_dir = 'c:\sap\'.
    CALL METHOD cl_gui_frontend_services=>directory_exist
      EXPORTING
        directory            = v_dir
      RECEIVING
        result               = v_bol
      EXCEPTIONS
        cntl_error           = 1
        error_no_gui         = 2
        wrong_parameter      = 3
        not_supported_by_gui = 4
        OTHERS               = 5.IF NOT v_bol IS INITIAL.
      WRITE:/ 'Directory exists.'.
    ELSE.
      WRITE:/ 'Directory does not exist.'.
    ENDIF.
    Regards,
    Sachin M M

  • Call ABAP function module from script?

    Hi,
    I have an ABAP function module, which works fine when I call it in a transformation.
    Since I don't need to execute this function for each record but rather for each file I process, I would like to move the call from the DataFlow to a script in the WorkFlow. When I click on the 'functions' button the ABAP FM is available in my SAP Datastore, so I drag and drop it into my script. I also make sure to populate all required variables.
    There are no error messages or warning when I check my job definition.
    When I execute it, I get the following RFC error:
    Function call <xxx  ( abcd ) > failed, due to error <150413>: <RFC CallReceive exception <FUNCTION_NOT_FOUND>.>.
    Is it just not possible to call an RFC enabled function module in SAP from a script or am I doing something wrong here?
    Thanks,
    Jan.

    Could you please let me know how I can call an abap function module from a transformation? (from abap xslt program). I know how we can call methods of a class from the transformations, but no idea how we can call function modules. Any suggestions or a sample code snippet towards this will be very useful for me.
    Thanks,
    Shashi.

  • Passing an XML file from WebDynpro app to ABAP function module

    Hi all,
    I'm stuck with a problem, and am hoping one of you could let me know how to proceed:
    I need to pass an XML file (or at least the entire content of the XML) from my WebDynpro application to a backend ABAP function module. What I tried was this:
    In my WebDynpro app, I read the XML and convert the content into one long string (using java.io.FileReader and java.io.BufferedReader). In my ABAP function module I created an import parameter of type String. I then imported the ABAP Function module into my WebDynpro app as a model. I then tried to pass the XML string to the ABAP module. What happens is this:
    If the size of the string (XML) happens to be less than 255 characters, then it works. That is, the string is passed to the ABAP function module and I can see the contents. However, if the XML string happens to be greater than 255 characters, then it does not work. The string at the ABAP side is empty. Surprisingly, the ABAP module does not throw an error either. It just displays an empty string.
    Could you please tell me what the problem is?
    Thanks & Regards,
    Biju

    Hi Biju ,
    Welcome to SDN.
    If the import parameter is defined as type string it should work, however did you check whether your application pass it properly?
    I have applications using strings as import parameters working fine. (webapplications (BSP) to RFC)
    Regards
    Raja

  • Help on ABAP Function Module (Unit 1)

    Hello ABAP Experts,
    I need help with the below mentioned lesson plan. I donot have source code for The ABAP Function Module - BC401_GET_SEP_STRING. For the Source Code Solution in the Lesson Plan to work, I need the source code for the above mentioned function module.
    The Lesson Plan with Solution is posted below:
    Exercise 1 
    Unit: Data Types and Data Objects in Detail
    Topic: Defining Data Types and Data Objects
    Basic Statements
    Processing Character Strings
    At the conclusion of these exercises, you will be able to:
    u2022     Define structure types locally in the program
    u2022     Define elementary and complex data objects
    u2022     Split strings
    u2022     Use conversion rules
    u2022     Display the contents of data objects in lists
    In this exercise, you will use a template to create a program that receives a single data record from the database table SFLIGHT in form of a character string. The program will split the this character string into its components and display it formatted in a list.
    Because the focus of this exercise is not on the transfer of data as a character string, we will use a function module that will provide us with the required database. This will simulate actual cases, such as data transfer from an external system.
    Program: ZBC401_##_SPLIT_STRING
    Template: SAPBC401_DTOT_SPLIT_STRING
    Model solution: SAPBC401_DTOS_SPLIT_STRING
    is your two-digit group number
    1-1 Copy the program, SAPBC401_DTOT_SPLIT_STRING and give it the new name ZBC401_##_SPLIT_STRING.
    1-2 Familiarize yourself with the main body of the program. Pay special attention to the content of the data object datastring after the function module call. Use the Debugger to do this, and/or display the character string in a list. (The function module itself is here seen as a black box. For this exercise, it is not necessary to understand its construction.)
    1-3 To be able to split the character string into its components you must first remove the ## characters. Remove the two leading separators from the character string first. Then copy the initial part up to the closing separators to the auxiliary variable set_string. For this, set_string has to be defined appropriately.
    1-4 Now use the separators to split the contents of the auxiliary variable set_string into the structure wa_flight_c. The latter is typed with the local program structure type st_flight_c. You still have to comment out the components of this structure type and assign them an appropriate type.
    1-5 As a test, display the fields of the structure, wa_flight_c in a list.
    1-6 In the list displayed in exercise 1-5, you should have observed that some of the fields were displayed without formatting u2013 for example, the PRICE field. Your next step is to change this.
    To do this, convert the data you have extracted by copying it to data objects with suitable types. Also, not all components of wa_flight_c are to be displayed.
    For this purpose, a structure wa_flight has already been defined. It is typed with the structure type st_flight. You must comment out the components of st_flight and find appropriate types for these components for the formatting. Then copy the identically-named components of the character-type structure wa_flight_c to the fields of the structure wa_flight.
    Display the contents of the structure wa_flight in a list. Use the appropriate formatting options for the WRITE statement for the fldate and price components.
    Data Types and Data Objects in Detail Solution 1
    Unit: Data Types and Data Objects in Detail
    Topic: Defining Data Types and Data Objects
    Basic Statements
    Processing Character Strings
    REPORT sapbc401_dtos_split_string.
    TYPES:
    BEGIN OF st_flight_c,
    mandt(3) TYPE c,
    carrid(3) TYPE c,
    connid(4) TYPE n,
    fldate(8) TYPE n,
    price(20) TYPE c,
    currency(5) TYPE c,
    planetype(10) TYPE c,
    seatsmax(10) TYPE n,
    seatsocc(10) TYPE n,
    paymentsum(22) TYPE c,
    seatsmax_b(10) TYPE n,
    seatsocc_b(10) TYPE n,
    seatsmax_f(10) TYPE n,
    seatsocc_f(10) TYPE n,
    END OF st_flight_c,
    BEGIN OF st_flight,
    carrid(3) TYPE c,
    connid(4) TYPE n,
    fldate TYPE d,
    price(9) TYPE p DECIMALS 2,
    currency(5) TYPE c,
    planetype(10) TYPE c,
    seatsmax TYPE i,
    seatsocc TYPE i,
    END OF st_flight.
    DATA:
    datastring TYPE string,
    set_string TYPE string,
    wa_flight_c TYPE st_flight_c,
    wa_flight TYPE st_flight.
    START-OF-SELECTION.
    CALL FUNCTION 'BC401_GET_SEP_STRING'
    EXPORTING
    IM_NUMBER = '1'
    IM_TABLE_NAME = 'SFLIGHT'
    IM_SEPARATOR = '#'
    IM_UNIQUE = 'X'
    IMPORTING
    ex_string = datastring
    EXCEPTIONS
    no_data = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE a038(bc401).
    ENDIF.
    SHIFT datastring BY 2 PLACES.
    FIND '##' IN datastring.
    IF sy-subrc <> 0.
    MESSAGE a702(bc401).
    ENDIF.
    SPLIT datastring AT '##' INTO set_string datastring.
    SPLIT set_string AT '#' INTO
    wa_flight_c-mandt
    wa_flight_c-carrid
    wa_flight_c-connid
    wa_flight_c-fldate
    wa_flight_c-price
    wa_flight_c-currency
    wa_flight_c-planetype
    wa_flight_c-seatsmax
    wa_flight_c-seatsocc
    wa_flight_c-paymentsum
    wa_flight_c-seatsmax_b
    wa_flight_c-seatsocc_b
    wa_flight_c-seatsmax_f
    wa_flight_c-seatsocc_f.
    MOVE-CORRESPONDING wa_flight_c TO wa_flight.
    WRITE: /
    wa_flight-carrid,
    wa_flight-connid,
    wa_flight-fldate DD/MM/YYYY,
    wa_flight-price CURRENCY wa_flight-currency,
    wa_flight-currency,
    wa_flight-planetype,
    wa_flight-seatsmax,
    wa_flight-seatsocc.

    this FM is to get one element value from the XML
    if you want to convert the whole XML use FM SMUM_XML_PARSE
    Regards
    Raja
    Kindly close your previous threads and assing points.
    Re: Creation of SIMPLE TRANSFORMATIO(ST)for deserialisation of XML ->ABAP data.

  • Web Services  from ABAP function modules return values- leading zeros

    I am using several web services from SAP CRM (5.0) that were created from Function modules ( I am assuming that that they are in ABAP).
    I can call the web services fine and they work as expected, but I am seeing a lot of leading zeros in the return values of fields in tables from the Web service.
    The ABAP er’s are telling me that they cannot see the leading zero’s.
    So my question is where these are appended to the values in the whole process. When I execute the Function Module in SAP CRM from transaction SE37 I can see the leading zeros. So I think that this is something that has to be handled by the ABAP er’s and not in the client consuming the web service.
    Are the functions in SAP CRM that can remove leading zeros for fields in a table (that is an export parameter?)
    Jawahar

    Hello Jawahar
    If you run your (RFC-enabled) function modules using the SAP-GUI (i.e. in dialog) then the GUI automatically replaces leading zero when the function module returns any data. However, calling the same function module remotely you will always see these leading zeros.
    These so-called conversion exits are defined as attribute of domains in the ABAP dictionary. If the function module used for the WebService is a standard fm then you have little chances to get rid of the leading zero. Perhaps the WebService has some attribute to suppress conversion exits or activate them when retrieving the data.
    Regards, 
       Uwe

  • Function Module tto check special characters in a field

    Hi All,
    I have a requriemnt where i need to make sure there are no special characters allowed
    in a paremeter ( is there any functional module to check it)
    r anyway to work with
    Thank in advance for u replies.
    Regards,
    Riyaz.

    DATA: vergleich_string(100) VALUE
              'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
      CONCATENATE vergleich_string ' 1234567890,./!@#$%&*-_+=~|\[{]}()"'
                                                   INTO vergleich_string.
    use condition.
    if var ca vergleich_string.
    raise error message.
    endif.

  • Function Module to validate date

    Hi,
    Is there a Function module to validate date in transfer rules or update rules. I checked the forum, couldn't find an answer. Any help is appreciated
    Thanks
    Bala

    You should be able to use this FM:
    CALL FUNCTION 'RSAR_DATE_CHECK_PLAUSIBILITY'
      EXPORTING
        i_date                          = yourdate
    EXCEPTIONS
       PLAUSIBILITY_CHECK_FAILED       = 1

  • Function module to convert date form yyyy/mm/dd to dd/mm/yyyy format

    Can any one tell me Function module to convert date form yyyy/mm/dd to dd/mm/yyyy format?

    have a look at the WIKI FAQs...they are very useful
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/abapDevelopmentand+Programming&
    For this it says:
    <i>How to convert a date to internal or external format?
    Use the functions modules CONVERT_DATE_TO_EXTERNAL or CONVERT_DATE_TO_INTERNAL
    to convert the date. When converting to external format, the date format from the user's user profile will be used. When converting to internal format, the result will be in YYYYMMDD format.</i>

  • Required function module to get date one year in the past.

    Hi,
    Required function module to get date one year in the past.
    Thanks and regards,
    M.R.Reddy.

    Hello,
    You can check this:
    DATA:
    V_DATE1 TYPE D,
    V_DATE2 TYPE D.
    V_DATE1 = SY-DATUM.
    TRY.
        CALL METHOD CL_HRPAD_DATE_COMPUTATIONS=>SUBTRACT_YEARS_FROM_DATE
          EXPORTING
            START_DATE = V_DATE1
            YEARS      = 1
          RECEIVING
            DATE       = V_DATE2.
      CATCH CX_HRPA_VIOLATED_POSTCONDITION .
    ENDTRY.
    WRITE:
    / V_DATE1, / V_DATE2.
    Hope this helps.
    Br,
    Suhas

  • Function module to conver date to internal format

    Can anybody say what is the function module used to convert the format of the date which is taken from excel sheet to the sap format. If so pls tell me how to use that function module.

    Currently my date is getting printed in format 05262005.
    I want the output as 26 May, 2005.
    I have tried using Set date mask option but it is not picking up in the output.
    Code:
    This code yields as 12 march 2006.
    DATA: ZTEMP(9). 
    CLEAR: ZTEMP, ZDD, ZMMM, ZYYYY. 
    CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT' 
    EXPORTING 
    INPUT = IS_DLV_DELNOTE-HD_GEN-CREA_DATE 
    IMPORTING 
    OUTPUT = ZTEMP. 
    ZDD = ZTEMP+3(2). 
    ZMMM = ZTEMP+0(3). 
    ZYYYY = ZTEMP+5(4).
    http://www.sap-img.com/abap/abap-program-output-of-date-format.htm

  • Calling an ABAP function module

    Hi friends,
    I am developing an application in EP6 SP2 using JSPDynPage from which, want to call an ABAP function module that returns table and show the values from this table in this application.
    I went thru various blogs and APIs. I am confused between SAP JCO, JCO client service and connector framework. Do u have any documentation on how to connect to R3 systems and call a function module, retrieve results etc.
    Regards,
    Nilz

    JCo is the point to start. This gives you low level access to all rfc functions. Everything else (accept BSP and Web dynpro) are just layers of encapsulation around the low level JCo function.
    The steps are always like this:
    call the sap system for rfc login
    prepare data areas and call in java
    call the rfc in the R/3 system
    handle exceptions
    logoff and free ressource
    continue with data obtained in R/3
    There is a lot of material around jco. One book that is fairly ok is :
    SAP Interface Programming
    A comprehensive reference for RFC, BAPI, and JCo programming
    J. Meiners, W. Nüßer
    SAP PRESS ISBN 1-59229-034-5
    This helps you navigate through the wealth of information also at SDN

  • BW/ABAP- Function module is called infinitely by Datasource Extractor.

    Hi All,
    A quick ABAP question related to Function Modules and BW data source extractors.
    I’ve written a function module to select data from a database and simply output the data as a table. I then created a text Datasource using transaction rso2 and set it to Extraction by Function Module.
    When I test this using transaction rsa6, I can manipulate the number of calls to my function module using the Display Extra Calls field.
    However, when I test this using transaction rsa1, my function module seems to be called infinite times. So, the number of records being retrieved is increasing exponentially and finally ends with a dump.
    My question: Do I need to include something in my code such that the Function Module by itself will only be called once?
    Or is there some configuration for the Datasource that will limit my function module call to once only.
    Tried so far
    • Introducing a static variable in the function module that exits as soon as the value is greater than 1.
    o Is there another way out?
    Regards,
    Preethi.

    You need to raise the EXEPTION NO_MORE_DATA afte the last record is populated in the output table. Otherwise the program goes into an infinite loop.
    * From now on records get fetched from the database or gets read from the internal table
        FETCH NEXT CURSOR v_cursor
                   APPENDING CORRESPONDING FIELDS
                   OF TABLE <internal table>
                   PACKAGE SIZE i_s_if-maxsize.
        IF sy-subrc <> 0.
          CLOSE CURSOR v_cursor.
          RAISE no_more_data.
        ENDIF.
    * Populate the Output Data Structure into table E_T_DATA and you need to raise the EXEPTION NO_MORE_DATA and close the cursor to avoid any memory leaks

Maybe you are looking for

  • Add a link to an image in iBooks?

    Is this possible? I can't seam to add any links to an image that I placed in the document.

  • Batch import of zipped and other types of files

    Hi, Has anyone out there try to do a batch import of zipped or other types of files yet?

  • Export is not / Backup

    I found in oracle docs that export is the logical backup my question is can we use this as Backup. If this used for small database which database is small, are not they critical?. And if i have export what may be the corruption,worst senerio or how l

  • FM to change task list status (Tcode IA06)

    Hi all, I need a FM to  change the task list status. Tcode IA06.. I have got fm to get the status of task list...CP_EX_PLAN_READ..but not able to fine one to change/. (Given: Group, Group counter and profile..after this scrrn another screen comes...c

  • Cisco, make the Mediahub webinterface open-source.

    It is a bold sugestion and probably never going to happen but, (as we say in Holland) you always miss of you don't shoot. The Mediahub webinterface is not near working properly and I don't think Cisco wants to put a lot of effort in it. So, my sugges