ABAP programming: Data validation

Hi everybody,
I wanted to know how to display error messages if a user enters invalid  data at the selection screen in a particular select-options field. Also the selection screen should be redisplayed after the message.
thanks

Hi,
  Check this code
REPORT z_sdn.
TABLES:
  vbak.
DATA:
  w_vbeln TYPE vbak-vbeln.
SELECT-OPTIONS:
  s_vbeln  FOR vbak-vbeln.             " Sales Document
*                 AT SELECTION-SCREEN ON s_vbeln EVENT
AT SELECTION-SCREEN ON s_vbeln.
* Subroutine to validate the sales document entered by user.
  PERFORM f0000_validate_sales_doc.
START-OF-SELECTION.
  WRITE: / 'TEST'.
*&      Form  f0000_validate_sales_doc
*       text
FORM f0000_validate_sales_doc .
  IF s_vbeln[] IS NOT INITIAL.
* Select query to fetch sales document
    SELECT vbeln                       " Sales Document
      FROM vbak
      INTO w_vbeln
     UP TO 1 ROWS
     WHERE vbeln IN s_vbeln.
    ENDSELECT.                         " SELECT vbeln
    IF sy-subrc NE 0.
      MESSAGE 'The entries you have specified do not exist in master table' TYPE 'E'.
    ENDIF.                             " IF sy-subrc NE 0.
    CLEAR w_vbeln.
  ENDIF.                               " IF s_vbeln IS NOT INITIAL
Regards
Abhijeet

Similar Messages

  • View ABAP program data in PDF

    Hello Experts,
    I am working on program to display the invoices data in PDF through ABAP program. For this i have used cl_gui_html_viewer and ALV grid. everything works fine but one. When I click on the PDF preview button on screen then for first PDF its working fine, but when i click on the another PDF preview button then it displays blank screen. In case of rerunning the program it again works fine only for first PDF preview. if anybody have idea regarding this issue please share it with me. FYI i am attaching necessary code with this. 
    Thanks,
    Avadhut

    Hi Alok,
    Here is something wrong in the code i have used it to display PDF.
    METHOD on_link_click.
        DATA : l_str_content TYPE zebd_send_content.
        READ TABLE m_tab_content INDEX row INTO l_str_content.
        DATA: l_xml  TYPE REF TO cl_xml_document.
        CREATE OBJECT l_xml.
        CASE column.
          WHEN 'PRVW'.
            g_attachment_string = l_str_content-attachment.
            CALL FUNCTION 'Z_EBD_PDF_SHOW'
              EXPORTING
                i_id = l_str_content-id
                i_pdf_string = g_attachment_string.
            CREATE OBJECT g_rcl_html_control
              EXPORTING
    *            shellstyle         =
                parent             = g_rcl_html_container
    *            lifetime           = lifetime_default
    *            saphtmlp           =
    *            uiflag             =
    *            name               =
    *            saphttp            =
    *            query_table_disabled = ''
    *          EXCEPTIONS
    *            cntl_error         = 1
    *            cntl_install_error = 2
    *            dp_install_error   = 3
    *            dp_error           = 4
    *            others             = 5
            IF sy-subrc <> 0.
    *         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.
    FUNCTION Z_EBD_PDF_SHOW .
    *"*"Local Interface:
    *"  IMPORTING
    *"     REFERENCE(I_PDF_STRING) TYPE  STRING
    *"     REFERENCE(I_ID) TYPE  STRING
      g_attachment_string = i_pdf_string.
      g_id = I_ID.
      call screen 0101 STARTING AT 5 5.
    ENDFUNCTION.
    ***INCLUDE LZ_EBDO01 .
    *&      Module  STATUS_0100  OUTPUT
    *       text
    module STATUS_0100 output.
      set pf-status '100'.
    *  SET TITLEBAR 'xxx'.
      clear: g_url, g_tab_pdf_data,g_attachment_binary.
      free: g_rcl_html_container, g_rcl_html_control.
      create object g_rcl_html_container
        exporting
          container_name = 'PDF'.
      create object g_rcl_html_control
        exporting
          parent = g_rcl_html_container.
    *      lifetime = cl_gui_html_viewer=>lifetime_dynpro.
    *    CREATE OBJECT g_rcl_pdf_control
    *      EXPORTING
    *        parent            = g_rcl_html_container
    **        lifetime          =
    **        shellstyle        =
    **        autoalign         =
    *      EXCEPTIONS
    *        cntl_error        = 1
    *        cntl_system_error = 2
    *        create_error      = 3
    *        lifetime_error    = 4
    *        others            = 5
    *    IF sy-subrc <> 0.
    **     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    **                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *    ENDIF.
    * Convert xstring to binary table to pass to the LOAD_DATA method
      clear g_attachment_binary.
      call function 'SSFC_BASE64_DECODE'
        exporting
          b64data = g_attachment_string
        importing
          bindata = g_attachment_binary
        exceptions
          others  = 8.
      clear g_tab_pdf_data.
      call function 'SCMS_XSTRING_TO_BINARY'
        exporting
          buffer     = g_attachment_binary
        tables
          binary_tab = g_tab_pdf_data.
    * Load the HTML
      clear g_url.
      CONCATENATE g_id '.pdf' into g_id.
      g_rcl_html_control->load_data(
         exporting
           url          = g_id
           type         = 'application'
           subtype      = 'pdf'
         importing
           assigned_url         = g_url
         changing
           data_table           = g_tab_pdf_data
         exceptions
           dp_invalid_parameter = 1
           dp_error_general     = 2
           cntl_error           = 3
           others               = 4 ).
    *     CALL METHOD g_rcl_pdf_control->open_document
    *    EXPORTING
    *      url               = g_url
    *    EXCEPTIONS
    *      cntl_error        = 1
    *      cntl_system_error = 2
    *      others            = 3
    *  IF sy-subrc <> 0.
    **   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    **              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *  ENDIF.
    ** Show it
      g_rcl_html_control->show_url( url = g_url
        in_place = 'X' ).
    endmodule.                 " STATUS_0100  OUTPUT
    Thanks,
    Avadhut

  • ABAP - input data validation

    I have been trying to look through the forum for means of input data validation to no vail. It is necessary to validate data before saving in database. There is an interface IF_WD_VALIDATION out there which seems to handle this task but no more information is provided on how to use it. Does anyone know more about it?
    By validation, I mean verification of:
    data type
    data value (min value, max value)
    data dependence (a<b, or a>b)
    Your suggestion is appreciated.

    There is more solution to validate fields.
    If you import adaptiev RFC model, Dynpro will make validation.
    Secend vay is to put validation in setters function and raise exception if is not valide
    public void setName(String name)
      if(name.length() > 100) throw new Exception("name is to loong");
      this.name = name;
    or mabie more simpliest is to make boolean function check()
    If you want stop workflow in not valide case you can do with
    wdComponentAPI.getMessageManager().raiseException("message", true)

  • XSD VALIDATION IN ABAP PROGRAM

    Hi,
    I have a requirement where in a report i am picking xml file from the presentation server (desktop) and then i am parsing the xml file using FM "SMUM_XML_PARSE" (first i use FM SCMS_BINARY_TO_XSTRING and then SMUM_XML_PARSE). after using the function SMUM_XML_PARSE i get the xml data in my internal table and then my report uses that data for some processing. This all is working fine .
    My issue is that how do i do a XSD VALIDATION for the xml file that i am reading . I would have liked to do a xsd validation after i import the xml file and throw error if the xml file is not as per its xsd.As i am not using any middleware technology like XI/ WTX which have XSD validation functionality i am not sure how to achieve this in abap program.

    Hi,
    I think you're right, iXML can only validate DTD via its if_ixml_parser->set_validating method (you can find this information in SAP SDN article "ABAP XML Mapping", as of release 6.10, I couldn't find any other reference saying that xsi:noNamespaceSchemaLocation is supported since then).
    By looking at SDN, I saw an external link about XSD to DTD conversion via XSLT (http://crism.maden.org/consulting/pub/xsl/xsd2dtd.xsl), but I don't have any idea if it works. On another thread, people used OS command to do XML/XSD validation, but didn't describe what they ran exactly (anyway, that means using any external tool).
    Sandra

  • How can i print data in smartforms from ABAP program.

    Dear gurus:
    in my abap program i process require data, and saved in a internal table.
    how can l print the data in smartforms.?
    who can give me a code sample is better:)
    reward all helpful advise.

    Try this....
    1) Tcode --> SmartForms
    2) Form name --> Z_SF_TEST Create
    3) Under Global settings
    a) Form Interface  
        Table Tab
       ITAB LIKE EKPO
    b) GLOBAL Definitions
    WA_NETPR LIKE EKPO-NETPR
    In smart forms if we want to display quantity and currency fields. We can't directly display currency field and quantity fields
    For that we have to create an extra variable in global definitions
    Ex: netpr FIELD of EKPO
    CREATE program lines and specify WA_NETWR = itab-netpr.
    4) RT CLick on main Window
       CREATE --> TABLE
      Click Table painter
    DEFAULT %LTYPE will be Created
    a) If you want more like Header footer etc add by rt click on %LTYPE1
    Table (Tab)
    %LTYPE  Radio(SELECT) 5 CM 5 CM 6 CM
    CLICK on DATA (Tab)
    INTERNAL TABLE ITAB LIKE ITAB
    5)RT click on table control and create --> program lines
    General attribute (Tab)
    INPUT PARAMETER               OUTPUT PARAMETER
    itab                               WA_NETPR
    Code Area
    WA_NETWR = ITAB-NETPR.
    6) RT CLcick on table ctl and create 3 text to display the fields
    a) % text1 +button(insert field)
       FIELD name &itab-ebeln&
    Output options (tab)
    Check New line   LINETYPE   %Ltype1
    check new cell
    b) % text2
       & itab-ebelp&
    output options
    check new cell
    c) % text2
       & wa_netpr&
    output options
    check new cell
    <b>Report ac
    Tables ekpo.
    Data: itab1 like ekpo occurs 0 with header line.
    select * into table itab1 from ekpo.
    Call function module --> smart form function module and pass your internal table</b>
    Regards,
    SaiRam

  • Getting Data from Maintenance view V001N into ABAP program

    Hello Experts,
    I have to fetch data from the maintenance view V001N in my ABAP program.  I have used select statement in my program but I am getting a syntax error  'V001N is not defined in the ABAP Dictionary as a table, projection view or database view. '.  V001N is a Maintenance view.
    Can anybody help me out how to get the data from that maintenance view into the internal table of my ABAP program.
    Regards.

    Sunil,
    check these threads
    https://forums.sdn.sap.com/click.jspa?searchID=18906946&messageID=6074746
    https://forums.sdn.sap.com/click.jspa?searchID=18906946&messageID=6088233
    so query on the tables which are used in the view
    Thanks
    Bala Duvvuri

  • How to extract data from BPC InfoCube via ABAP program?

    Hi experts!!
    I tried to extract data from a BPC InfoCube via ABAP program, but I did'n have succeed.
    I used the function 'RSDRI_INFOPROV_READ' to extract data from standard InfoCubes such as '0COPC_C07' and it run OK! However, when I change the InfoCube name to '/CPMB/WAIX8NE' (BPC InfoCube), everything goes wrong...
    Is there any difference between extracting data from BPC and standard InfoCubes?
    Thank you all!

    Moderator message - Welcome to SCN.
    But please do not cross and duplicate post.
    Thread locked.
    Rob

  • Error while calling ABAP program from Data Services

    Hi All,
    We have a ABAP program which accepts two parameters 1] a date 2] a string of comma separated ARTICLE numbers .
    We have used a ABAB transform in ABAP dataflow which refers this ABAP program.
    If I pass a string of 6 articles as second parameter the job executes successfully
    But if i pass 9 articles as follows
    $GV_ITEM_VALUES='3564785,1234789,1234509,1987654,1234567,2345678,3456789,4567890,5456759';
    i get the following error
    ABAP program syntax error: <Literals that take up more than one line are not permitted>.
    The error occurs immediately after ABAP dataflow starts, ie even before the ABAP job gets submitted to ECC
    I am using BODS 4.2 . The datatype of $GV_ITEM_VALUES is varchar(1000).
    The ABAP program that gets generated by the DS job has the following datatype for this parameter
    PARAMETER $PARAM2(1000) TYPE C
    Is there a different way to pass string characters to ABAP transform in data services?
    I have attached the screen shot of trace log and error
    Regards,
    Sharayu

    Hi Sharayu,
    The error your getting is because the  literals exceeds more than 72 characters.
    It seems that the length of the string is exceeding more than 72 character.
    Can you check the following in ECC GUI
    Go to Transaction SE38=>Utilities=>Settings=>ABAP Editor=>Editor=> Downwards -Comp.Line  Length(72).
    The checkbox which defines length 72 must be clicked so the error is coming. Can you uncheck the checkbox and then try passing the parameter $GV_ITEM_VALUES using the BODS job
    Regards
    Arun Sasi

  • Sending Data to PDF Forms from ABAP Program.

    Hi Experts,
    I left ABAP Programing for a while around 1+ years Due to some personal problems
    Now I have struck up with new issue. Its ADOBE PDF forms.
    I am Entirely new to this topic & knows about Nothing.
    My requirement is to display a report in PDF form. Its totally Independent form from NACE.
    I have written a Driver program & retrieved all the DATA into a Final internal table.
    Now All that I need is to display the same Internal Table data into PDF form output.
    Can anyone help me how to send this data(47 records in Internal table with 8 fields in Internal table) to PDF.
    Please help me out Experts with any suggestions.
    Thanks & Regards,
    Dileep .C

    Hi,
    if u pass your internal table to smartform we can achieve . because we can convert smartform output into pdf easily.
    Regards,
    karthikeyan k s,
    Edited by: karthikeyanks on Nov 19, 2010 12:58 PM

  • Reading XML Data from ABAP Program?

    Hi,
    How do I read XML Data from an ABAP Program? For example if I have the below basic XML Code-
    <xml>
    <Name> Thiru </Name>
    <Age> 24 </Age>
    <City> chennai </Chennai>
    </xml>
    How do i read the data within the Name,Age, and City tags into variables in the ABAP Program?
    Regards,
    Thiru

    if you decide to do in XSLT, I have a sample list here:
    XML file like this:
    <?xml version="1.0" encoding="UTF-16"?>
    <F>
    <P1>
    <t_1>value1</t_1>
    <t_2>testvalue</t_2>
    </P1>
    <P2>
    </P2>
    </F>
    XSLT file like this:
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sapxsl="http://www.sap.com/sapxsl" version="1.0">
    <xsl:strip-space elements="*"/>
    <xsl:template match="F">
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <<b>DOCUMENT</b>>
    <xsl:apply-templates/>
    </<b>DOCUMENT</b>>
    </asx:values>
    </asx:abap>
    </xsl:template>
    <xsl:template match="P1">
    <ENTRY>
    <<b>T_1</b>><xsl:value-of select="t_1"/></T_1>
    <<b>T_2</b>><xsl:value-of select="t_2"/></T_2>
    </ENTRY>
    </xsl:template>
    </xsl:transform>
    ABAP program like this:
    DATA: BEGIN OF wa_upload,
    text(255) TYPE c,
    END OF wa_upload,
    itab_upload LIKE TABLE OF wa_upload,
    BEGIN OF wa_document,
    t_1 TYPE string,
    t_2 TYPE string,
    END OF wa_document,
    itab_document LIKE TABLE OF wa_document.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'XXXXX'
    filetype = 'ASC'
    TABLES
    data_tab = itab_upload.
    CALL TRANSFORMATION zrappel_xml_test
    SOURCE XML itab_upload
    RESULT <b>document</b> = itab_document.
    You should pay attention to the bold words.
    hope it will be helpful
    thanks

  • How to get data in ABAP program from multicube in external BW system

    Hi friends,
         I want to get data from one multicube which resides in an external BW system, in my ABAP program internal table. Is there any SAP standard RFC / BAPI for this or is there any other way around or I have to design my own program to get the data ?
        To make my requirement clearer, my ABAP program is in one BW box and the above mentioned multicube in another BW box. I want to get data from the multicube into my program.
        Any help is appreciated with points.

    Look at the following FM; you may find the FM RSDRI_INFOPROV_READ_RFC useful.
    Call the FM in your program and read data and update.
    RSAD_INFOCUBE_READ_REMOTE_DATA
    RSDRI_INFOPROV_READ_RFC
    Ravi Thothadri

  • How to list the abap programs order by updated date in ECD

    Hi experts,
    how to list the abap programs order by updated date in ECD?
    thanks.

    I wrote a custom program for displaying Z* development work into an ALV report. 2500 character limit prevents me from posting, message me your email and I'll send you source code.
    Edited by: Brad Gorlicki on Feb 18, 2010 11:25 PM

  • Execute ABAP Program - Error in Open File Cust_Dim.dat

    HI All,
    I am trying to Implement scenario of Data Service designer for Extract SAP Application data (page no. 181 Onwards). It is for transfer data from SAP ECC - KNA1 to MSSQL table.
    I have Data Service server install on my system.
    I have implement all the steps. When I execute job server. I am getting error like
    "Execute ABAP program <C:/Program Files/Business Objects/BusinessObjects Data Services/ZCUSTDIM_1.aba> error < Open File Error -- C:\Program Files\Business Objects\/Cust_Dim.dat>"
    Does anyone knows about this? I have tried to find lot in SDN but didn't find any solution.
    Thanks
    Ratnakar

    Hi all
    I was having the exact same problem as the one explained here.
    I was a little mixed up because I assigned full privileges on the destination folder to one specific account called installsap
    I used  this account for installing SAP BO Data Services. This account is the one configured on the Business Objects Data Services Service:
    However, I kept getting the same error, as if this account had not enough privileges over the folder.
    I saw that there is another Service called Server Intelligent Agent. I went through its configuration Properties by using the Central Configuration Manager, specifically within the Log On As Property and it seemed like a non specific System Account was configured there.
    Then I open the services.msc (Windows application) in order to see this very same service configuration and it had NOTHING specified there, nor a Local System Account nor an specific user account.
    So, I stopped the service and specified the installsap account I used for the Business Objects Data Services Service. After that I verified I could see this configuration through the Central Configuration Manager and now both tools showed the same.
    Then I started the SIA Service retried again executing the ABAP Data Flow and the Error in Open File was gone.
    It is how the SIA Service configuration looks like.
    By the way, I am not sure if the "Job Server Service" which was cited before in this thread is the same as the Server Intelligence Agent Service I modified
    Besides, although I've been using DS for quite a considerable amount of time, I have never heard of such "Job Server Service". Let me know if I am wrong.
    Anyways it worked for me and I hope it works for someone else who faces the same error.
    Best regards!

  • How to read data from an excel using abap program?

    Hi
    I have to write an abap program to read the contents of ms excel across various
    sheets. Can any one help me regarding this
    Thanks in advance
    Satish

    Hai Satish,
    <b>You save  all your Excel sheets as Text Tab Delimited.</b>
    And then for each teext file can be uploaded into your daabase table.
    See the Report that  i have done.
    REPORT Z_UPLOAD_TO_DATABASE_TABLE.
    TABLES:
      ZDETMAST.                        " Database table to be uploaded
    Data declaration of the structure to hold ZDETMAST(zdetcode) data  *
    DATA:
      BEGIN OF FS_ZDETMAST,
        CNT(3)      TYPE C,                " Client
        DETCODE(15) TYPE C,                " Det Code
        DETCAT(1)   TYPE C,                " Det category
        DETTYPE(2) TYPE  N,                " Det type
        DETDESC(30) TYPE C,                " Det description
        PFLAG(1)   TYPE C,                " Det Flag
        TOTALDR(10) TYPE C,                " Total DR
        TOTALCR(10) TYPE C,                " Total CR
      END OF FS_ZDETMAST.
    Internal table to hold ZDETMAST(zdetcode) data                     *
    DATA:
      T_ZDETMAST LIKE STANDARD TABLE OF FS_ZDETMAST.
    Function Module to upload ZDETMAST Data
    CALL FUNCTION 'GUI_UPLOAD'
       EXPORTING
         FILENAME                      = 'D:/ZDETMAST_2.TXT'
         FILETYPE                      = 'ASC'
         HAS_FIELD_SEPARATOR           = 'X'
        HEADER_LENGTH                 = 0
        READ_BY_LINE                  = 'X'
        DAT_MODE                      = 'DAT'
        CODEPAGE                      = ' '
        IGNORE_CERR                   = ABAP_TRUE
        REPLACEMENT                   = '#'
        CHECK_BOM                     = ' '
        VIRUS_SCAN_PROFILE            =
      IMPORTING
        FILELENGTH                    =
        HEADER                        =
        TABLES
          DATA_TAB                      = T_ZDETMAST
       EXCEPTIONS
         FILE_OPEN_ERROR               = 1
         FILE_READ_ERROR               = 2
         NO_BATCH                      = 3
         GUI_REFUSE_FILETRANSFER       = 4
         INVALID_TYPE                  = 5
         NO_AUTHORITY                  = 6
         UNKNOWN_ERROR                 = 7
         BAD_DATA_FORMAT               = 8
         HEADER_NOT_ALLOWED            = 9
         SEPARATOR_NOT_ALLOWED         = 10
         HEADER_TOO_LONG               = 11
         UNKNOWN_DP_ERROR              = 12
         ACCESS_DENIED                 = 13
         DP_OUT_OF_MEMORY              = 14
         DISK_FULL                     = 15
         DP_TIMEOUT                    = 16
         OTHERS                        = 17
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.                                 " IF SY-SUBRC <> 0.
    LOOP AT T_ZDETMAST INTO FS_ZDETMAST.
      WRITE:
        / FS_ZDETMAST-CNT,
         FS_ZDETMAST-DETCODE,
         FS_ZDETMAST-DETCAT,
         FS_ZDETMAST-DETTYPE,
         FS_ZDETMAST-DETDESC,
         FS_ZDETMAST-PFLAG,
         FS_ZDETMAST-TOTALDR,
         FS_ZDETMAST-TOTALCR.
    ENDLOOP.                               " LOOP AT T_ZDETMAST ...
    LOOP AT  T_ZDETMAST INTO ZDETMAST.
       IF SY-TABIX GE 2.
         INSERT ZDETMAST.
        DELETE ZDETMAST.
       ENDIF.                              " IF SY-TABIX EQ 2
    ENDLOOP.                               " LOOP AT  T_ZDETMAST
    Hope this helps you a lot.
    <b>You can also use ALSM_EXCEL_TO_INTERNAL_TABLE FM to have excel data in ITAB AND THEN YOU CAN INSERT DATA INTO DATABASE TABLE.</b>
    <b>Reward points if it helps you.</b>
    Regds,
    Rama chary.Pammi

  • How to pass table data to brf plus application through abap program

    Dear All,
    i have a question related to BRF Plus management through abap program.
    In brf plus application end, Field1,field2,field3 these 3 are importing parameters.
                                           Table1->structure1->field4,field5 this is the table,with in one structure is there and 2 fields.
    in my abap program, i am getting values of fields let us take field1,field2,field3,field4,field5.
    And my question is
    1) How to pass fields to BRF Plus application from abap program.
    2)How to pass Table data to BRF Plus application from abap program.
    3)How to pass Structure data to BRF Plus application from abap program.
    4)How to get the result data from BRF Plus application to my abap program.
    And finally , how to run FDT_TEMPLATE_FUNCTION_PROCESS.
    How do i get the code automatically when calling the function in brf plus application.
    Regards
    venkata.

    Hi Prabhu,
    Since it is a Custom Fm i cant see it in my system.
    Look if u want to bring data in internal table then there could be two ways::
    1) your FM should contain itab in CHANGING option , so that u can have internal table of same type and pass through FM,
    2) read values one by one and append to internal table.
    Thanks
    Rohit G

Maybe you are looking for