BDC (Flat File Data Validation) - Code

I am trying to validate flat file data BEFORE performing BDC (Call Trans. or Session)..
Pls help me out in below code for xk02..
DATA: BEGIN OF itab occurs 0,  "ITAB having flat file data.
      lifnr(16) ,
      bukrs(4),
      ekorg(4),
      END OF itab.
DATA: BEGIN OF int_final occurs 0,
      lifnr(16) ,
      bukrs(4),
      ekorg(4),
      status(6),
      message(6),
      END OF int_final.
DATA: int_final TYPE TABLE OF int_final.
DATA: wa_itab TYPE TABLE OF itab.
DATA: validate_itab TYPE TABLE OF itab. "VALIDATE_ITAB having master data.
DATA: wa_validate_itab TYPE TABLE OF itab.
FORM data_validation .
SELECT LFB1LIFNR LFB1BUKRS LFM1~EKORG INTO TABLE validate_itab
         FROM LFB1 INNER JOIN LFM1 ON LFB1LIFNR = LFM1LIFNR.
IF sy-subrc = 0.
SORT validate_itab BY lifnr bukrs ekorg.
ENDIF.
LOOP AT itab INTO wa_itab.
READ TABLE validate_itab WITH KEY
lifnr = itab-lifnr
bukrs = itab-bukrs
ekorg = itab-ekorg
BINARY SEARCH.
IF sy-subrc NE 0.
PERFORM f_error_log USING text-005. "Invalid Value Set
CONTINUE.
ENDIF.
ENDLOOP.
ENDFORM.                    " data_validation
*&      Form  f_error_log
FORM f_error_log USING l_message TYPE string.
CLEAR : fs_final.
fs_final-lifnr = itab-lifnr.
fs_final-bukrs = itab-bukrs.
fs_final-ekorg = itab-ekorg.
fs_final-status = text-014. "Error
fs_final-message = l_message.
APPEND fs_final TO int_final.
ENDFORM.                    " f_error_log
Thanks..

Hi GAurav,
I have a small question in th validation.
In LFM1~LIFNR does not contian any value how u r comparing both and one more thing After getting the data using GUI_upload u will get the data into validate_tab.
Loop at Vlidate_tab into wa_itab.
SELECT LFB1LIFNR LFB1BUKRS LFM1~EKORG INTO TABLE validate_itab
FROM LFB1 INNER JOIN LFM1 ON LFB1~LIFNR =  wa_itab-lifnr.
endllop.
Thanks,

Similar Messages

  • Flat file data needs to be update in MM02 t-code with bdc

    Hi,
    I have a requirement that flat file data shoud be update in MM02 t-code in basic data view (Units of measure ) columns .
    I have no access in dev. for  mm02 t-code but mm03 available.
    Can somebody suggest how to approach this. I know through recording (SHDB) i will do.
    But can i put mm03 instead of mm02 at the time of recording?

    Hi,
    thanks,
    But i want to update  these 4 fields data from flat file.
    How to catch in the FM ?
    MARM-MATNR   MARM-MEINH   MARM-UMREZ   MARM-UMREN
    Material                    UoM               Numerator          Denominator

  • Bdc upload file data into internal table problem with gui_upload fm

    Hello experts,
    my coding is like this ..
    data : begin of itab occurs 0 .
    field1 like mara-matnr,
    field2......
    etc,
    end of itab.
    data: file1 type string.
    parameter :file like rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
    static = 'X'
    mask = space
    field_name = 'FILE'
    CHANGING
    file_name = file.
    START-OF-SELECTION.
    FILE1 = FILE . "HERE I AM PASSING INTO STRING
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = FILE1
    FILETYPE = 'ASC'
    has_field_separator = 'X'
    TABLES
    data_tab = itab. " here the data is not populating from the file , it is giving the error like speified table not found.
    HERE i am getting the message like "specified table name not recgonised" . the data is not populating into the itab from the file.
    file structure is same as the internal table.
    I stored the file as .txt( ie in notepad).
    my file is like this..
    10000 200 323 sunndarrr.......
    i had a problem with this bdc , i am getting like "specified table name not recgonised" in the fm gui_upload while debugging.
    when i am using the ws_upload it is working fine.
    please guide me where i have done the mistake.
    thank you so much for all the replies.

    Hi,
    Have a look on the following code.
    TABLES: kna1.
    DATA: BEGIN OF itab1 OCCURS 0,
          str(255),
          END OF itab1.
    DATA: itab2 TYPE kna1 OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        filename                = 'D:\ABAP EVE\ffile1.txt'
        filetype                = 'ASC'
      TABLES
        data_tab                = itab1
      EXCEPTIONS
        conversion_error        = 1
        file_open_error         = 2
        file_read_error         = 3
        invalid_type            = 4
        no_batch                = 5
        unknown_error           = 6
        invalid_table_width     = 7
        gui_refuse_filetransfer = 8
        customer_error          = 9
        no_authority            = 10
        OTHERS                  = 11.
    IF sy-subrc <> 0.
      WRITE:/ 'sorry'.
    ELSE.
      LOOP AT itab1.
        SPLIT itab1-str AT ',' INTO itab2-kunnr itab2-name1.
        APPEND itab2.
      ENDLOOP.
      IF sy-subrc = 0.
        LOOP AT itab2.
          WRITE:/ itab2-kunnr,itab2-name1.
          INSERT INTO kna1 VALUES itab2.
        ENDLOOP.
        IF sy-subrc = 0.
          WRITE:/ 'inserted'.
        ELSE.
          WRITE:/ 'not inserted'.
        ENDIF.
      ELSE.
        WRITE:/ 'fail'.
      ENDIF.
    ENDIF.
    Flat file:
    10001,Sadney
    10003,Yogesh
    20005,Madan
    1.U need to define internal table with one field of max size
    2.upload the flat file data into that internal table
    3.split that internal table data into another internal table(having fields)
    <REMOVED BY MODERATOR>
    thanks,
    Chandu
    Edited by: Alvaro Tejada Galindo on Apr 30, 2008 12:17 PM

  • Flat file data load - ODS - Look up data in Startroutine

    Hi All,
    There is a requirement that I have two ODS say 1) ABC and XYZ.
    For Both ODS , We load flat file data.
    First we load data to ABC for current fiscal period
    During the data load to XYZ, We lookup part nos data in ABC for current fiscal period , if data there , for those part nos we load XYZ Flat file data.
    My requirement is that , I need to fetch part nos data from ABC for Fiscal period < current fisacl period.  Then I need to extract already loaded data for those part nos from XYZ and Mark the flag field as Non reportable .
    How can we achieve this ?
    Please advice
    Thanks
    Ajay

    Hi ,
    Thanks for your reply.
    I have done so. When I add lines of My Internal table data to DATA_PACKAGE, It gives the syntax error that both structures are not unique. We have several fields in XYZ ods but they are not in Communication structure.
    Thats the problem. Also , if I write the code , will it be executed for each datapackage. I mean , for each datapacket process , my code will fetch whole data from ABC and then from XYZ. Repetion will be there?
    Any other logic can i use ?
    Thanks
    Ajay

  • How to Merge Flat file data and DSO Data

    I have one DSO A which has more than 20 objects (5 of them are keys), which include 0comp_code,0gl_account,.  I have a Flat file which has the following fields ,COMPANY CODE, GLACCOUNT and SUPERVISOR ,EXECUTIVE,ANALYST. My requirement is to get a DSO with consolidated data from DSO A and Flat File data. That means for exapme, In my DSO A , I have US01 COMPANY CODE so when I merge the data in DSO C It should diplay the data for the supervisor exe and analyst for DSO A as well
    When I added with 2 DSOs A (ECC ) and B (Flat file)..C is getting the data from B and its appending the data for Flat file at the end...So I want to merge both...DSO A should match  up with DSO B flat file company code and gl account and should display the remaining fields
    I think its clear..Can any one let me know the solution ASAP...
    Note: We are on BI7.0 not 3.5...
    Thanks in advance

    I have the following key fields in DSO A :
    0COMP_CODE,OGL_ACCOUNT, 0CHRT_ACCT,0FISCVARNT,0FISCPER,0AC_DOC_NUMBER,0ITEM_NUM.
    Here are the total fields in Flat File:
    COMPANY CODE,GL ACCOUNT,SUPERVISOR,ANALYST,EXECUTIVE.
    Here am taking 0COMP_CODE  and 0GL_ACCOUNT  as key fileds in DSO B for Flat File...
    For every month there will be 5 to 6000 records for Flat file ...
    Thanks

  • How to convert the flat file data into sap tables . ?

    how to upload flat file data into sap table . before upload mapping is also there in some filds . any one can give me some steps how to upload and mapping . ?

    Hi
    See the sample code
    REPORT zmmupload.
    Internal Table for Upload Data
    DATA: i_mara like MARA occurs 0 with header line
    PARAMETERS: p_file LIKE ibipparms-path.  " Filename
    At selection-screen on Value Request for file Name
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    Get the F4 Values for the File
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
        IMPORTING
          file_name     = p_file.
    Upload the File into internal Table
      CALL FUNCTION 'UPLOAD'
        EXPORTING
          filename                = p_file
          filetype                = 'DAT'
        TABLES
          data_tab                = i_mara
        EXCEPTIONS
          conversion_error        = 1
          invalid_table_width     = 2
          invalid_type            = 3
          no_batch                = 4
          unknown_error           = 5
          gui_refuse_filetransfer = 6
          OTHERS                  = 7.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Upload the Data from Internal Table
      MODIFY MARA from TABLE i_MARA.
    Regards
    Anji.

  • How to store the flat file data into custom table?

    Hi,
    Iam working on inbound interface.Can any one tell me how to store the flat file data into custom table?what is the procedure?
    Regards,
    Sujan

    Hie
    u can use function
    F4_FILENAME
    to pick the file from front-end or location.
    then use function
    WS_UPLOAD
    to upload into
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'   "Function to pick file
        EXPORTING
          field_name = 'p_file'     "file
        IMPORTING
          file_name  = p_file.     "file
      CALL FUNCTION 'WS_UPLOAD'
       EXPORTING
         filename                       = p_file1
        TABLES
          data_tab                      = it_line
    *then loop at it_line splitting it into the fields of your custom table.
    loop at it_line.
              split itline at ',' into
              itab-name
              itab-surname.
    endloop.
    then u can insert the values into yo table from the itab work area.
    regards
    Isaac Prince

  • Urgent: Transport of Flat File Data Source

    While transporting flat file data source is it required to transport first in a separate request or everything can go in 1 request.
    Thank you,
    sam

    Hi,
    In this case it can go in one request as no replication is needed. But for other datasources, you need to send the datasources first in a separate request and then replicate the datasource in BW before you send the BW changes.
    Cheers,
    Kedar

  • Errors when loading flat file data

    We just test to load a very simple flat file data with only two lines and the two lines of data in preview of InfoSource is correct.  But when run InfoPackage to load data, the monitor of the InfoPackage shows the following errors (see in between two dashed lines below):
    Error getting SID for ODS object ZDM_SUBS
    Activation of data records from ODS object ZDM_SUBS terminated
    Error when assigning SID (details in long text)
    Error when assigning SID (details in long text)
    Error when assigning SID (details in long text)
    Error when assigning SID (details in long text)
    Error when assigning SID (details in long text)
    Error when assigning SID (details in long text)
    Error when assigning SID (details in long text)
    Error when assigning SID (details in long text)
    Value 'Bottom' (hex. '0042006F00740074006F006D') of characteristic ZRATEPLN contains invalid characters
    Value 'Dealer' (hex. '004400650061006C00650072') of characteristic ZCHANNEL contains invalid characters
    Value 'Bottom' (hex. '0042006F00740074006F006D') of characteristic ZRATEPLN contains invalid characters
    Value '19884/' of characteristic 0DATE is not a number with 000008 spaces
    Value '/19812' of characteristic 0DATE is not a number with 000008 spaces
    Value '19884/' of characteristic 0DATE is not a number with 000008 spaces
    In the flat file (excel sheet saved as a CSV file), for each row of the data, there are two fields which are start_date and end_date and the date format is MM/DD/YYYY and in the Transfer Rule, we transfer the date format from MM/DD/YYYY to YYYYMMDD which is required by DATS InfoObject type in BW.  If you need the excel sheet of data in order to answer our questions about the above errors, you can give us your e-mail address and we can send the simple two rows of data excel sheet file to you.
    Thanks!

    Hi Kevin,
    1.You can use lowercase letters in the values for your characteristics provided you have checked the lowercase checkbox in the general tab page of Create characteristic screen.But when you do so no masterdata tables,text tables, or another level of attributes underneath are allowed.
                            OR
    Use only upper case letters in your characteristic unchecking the above mentioned box.
    2.The date format in the CSV file should be yyyymmdd.It should have 8 characters . I guess there is something strange in your "calendardays" since I could not find 8 characters irrespective of the order.Do not forget to use zeroes.
    Hope this works.
    Reward if it is helpful.
    Regards,
    Balaji

  • Need help in laoding flat file data, which has \r at the end of a string

    Hi There,
    Need help in loading flat file data, which has \r at the end of a string.
    I have a flat file with three columns. In the data, at the end of second column it has \r. So because of this the control is going to the beginning of next line. And the rest of the line is loading into the next line.
    Can someone pls help me to remove escape character \r from the data?
    thanks,
    rag

    Have you looked into the sed linux command? here are some details:
    When working with txt files or with the shell in general it is sometimes necessary to replace certain chars in existing files. In that cases sed can come in handy:
    1     sed -i 's/foo/bar/g' FILENAME
    The -i option makes sure that the changes are saved in the new file – in case you are not sure that sed will work as you expect it you should use it without the option but provide an output filename. The s is for search, the foo is the pattern you are searching the file for, bar is the replacement string and the g flag makes sure that all hits on each line are replaced, not just the first one.
    If you have to replace special characters like a dot or a comma, they have to be entered with a backslash to make clear that you mean the chars, not some control command:
    1     sed -i 's/./,/g' *txt
    Sed should be available on every standard installation of any distribution. At lesat on Fedora it is even required by core system parts like udev.
    If this helps, mark as correct or helpful.

  • Flat File Data Loads to BI 7.0

    Hi Experts,
    Please update me what is the best approach i have to follow for the below scenario of Flat File Data Loads
    I will get data in Excel ....with Two worksheets....from the user
    My requirment is to place the file in Central location avaliable to the user and BW to update if any changes necessary  and want to load data(full0  to bw from file if there are any changes
    Please update me how to deal with this scenarion of Two work sheets,In a central location...
    Thanks

    Easiest thing would be to use a DSO with change log to handle the changes to pass onto to any cubes and load a full every night
    Then let the change log worry about any changes to the workbook
    You have to be careful about the DSO keys though for this to work properly
    Now to automate the loads - just how are you planning to create the infopackage as it will only read a csv and not the binary xls
    Well it will read the binary xls if you maybe use a dbconnect with a jdbc driver to read the xls (that's on my next thing to do - but if you are as your user id suggests a "bw learner" then that may be a bit complicated)
    The only other thign to do is to write a macro that automatically creates the csv file on the app server when the user quits the xls
    Or off course you can just dump the csv each night - but then that is a manual task and in systems I design I hate manual tasks as staff go on holiday and peopel change jobs and it's not really very SoX compliant

  • Converting Flat File data into XML

    Hi Experts,
    Consider the message type of the SENDER system and flat file data
    <dt_sender>
    <root>
    <header1>   0..1
        <f1>
        <f2>
        <f3>
    <header2>   0..1
        <f4>
        <f5>
        <f6>
    <item>        1..unbounded
        <f7>
        <f8>
        <f9>
        <f10>
        <f11>
        <f12>
    </item>
    abc     def     ghi     jkl     mno     pqr
    123     123     123     123     123     123
    456     456      456     456     456     456
    how to convert the flat file data into following XML data. please note that each field value is separated by TAB delimeter...wht parameters shld b used
    <root>
        <Header1>
            <f1>abc</f1>
            <f2>def</f2>
            <f3>ghi</f3>
        </Header1>
        <Header2>
            <f4>jkl</f4>
            <f5>mno</f5>
            <f6>pqr</f6>
        </Header1>
        <item>
            <f7>123</f7>
            <f8>123</f8>
            <f9>123</f9>
            <f10>123</f10>
            <f11>123</f11>
            <f12>123</f12>
            <f7>456</f7>
            <f8>456</f8>
            <f9>456</f9>
            <f10>456</f10>
            <f11>456</f11>
            <f12>456</f12>
        </item>
    points will be given to the correct answers
    Thanks in advance.
    FAisal
    Edited by: Abdul Faisal on Feb 29, 2008 5:53 AM

    Faisal,
    When you read the multiple recordset strucutre file then each record in txt file should have an header from which you can identiy which segment it should go.. and you identiy it by using the keyfiledValue in file adapter
    <root>
    <header1> 0..1
    <f1>
    <f2>
    <f3>
    <header2> 0..1
    <f4>
    <f5>
    <f6>
    <item> 1..unbounded
    <f7>
    <f8>
    <f9>
    <f10>
    <f11>
    <f12>
    </item>
    for this input file
    abc def ghi jkl mno pqr
    123 123 123 123 123 123
    456 456 456 456 456 456
    abc def ghi can be read using the file adater to header 1 usinfg key field value, but using the same file adapter you cannt put GHI into header2.
    else you should read whole row abc def ghi jkl mno pqr in single filed and write an UDF to split data to header1 and Header 2
    similarly you have to take care for item records also
    if your inout file is something like this
    abc def ghi
    jkl mno pqr
    123 123 123 123 123 123
    456 456 456 456 456 456
    abc identifies to Header 1
    JKL for Header 2  so on...
    read the whole line in single field  and write UDF to Split to header 1 and header 2 similary for item.

  • Conversion_Exit_Cunit_error occured while loading the Flat file data

    Hi
    Iam tryign to load Flat file data into an ODS, i am getting error like Error Conversion Cunit.
    Also we are using 0unit in the ODS for which CUNIT is a conversion rule
    Can you please suggest me why iam getting this error

    Hi Sunil
    Hope you can check whether you are loadig the flat file data from application server or Client workstation.
    May be if you are loading from Client work station you will face problem of this type.
    Try to check if any change in format in the file.
    at the end of the file delete the spaces.

  • Flat file data upload to ODS failed

    Hi guys,
    While loading the flat file data to ODS, it gets fails immediately without loading single record. Error message shows :: 
    <b>" Error when opening the data file <file name> (origin A)."
    "Error in the data request"
    "Error occurred in the data selection"</b>
    I am trying to load the data manually thru Infopackage and file is lying in the Application Server and full access given to it. But the important part is when we try to load the file again without doing any changes, it run fine and loads the data without any issues. This happens with every load & everyday.
    Any solutions?
    Regards
    Sanjiv

    Hi CK,
    Step-by-step Analysis status are as given::
    <b><Red> </b>        Data request sent off ?
    <b><No colour></b> RFC to source system successful ?
    <b><No colour></b> Does selectable data exist in the source
    <b><Red></b>         Data selection successfully started ?
    <b><Red> </b>        Data selection successfully finished ?
    <b><Red></b>         Processing error in source system reporte
    <b><No colour></b> RFC to Warehouse successful ?
    <b><Red>    </b>     Processing error in Warehouse reported ?
    <b><No colour></b> Processing successfully finished?
    <b><No colour></b> All reported data packets received?
    <b><No colour></b> All data packets complete ?
    <b><Green> </b>     Have all Processing Steps been Carried ou
    <b><Green></b>      All Data Packets Updated in all Targets?
    <b><Green>  </b>    Inadmissable Aggregation?
    Regards
    Sanjiv

  • Flat file data Source creation in BI7

    Hi ,
    I am trying to create flat file data source in BI7 to load master data.
    Aftre i enter all the details,while activating its giving me error like this
    Runtime Errors         DATA_LENGTH_NEGATIVE
    Except.                CX_SY_RANGE_OUT_OF_BOUNDS
    Can anyone suggest me abt this.
    Thanks
    Thiru

    Hi,
    In the datasource def go to the fields tab. Here check the values for the length og the field.
    Check whether all the values are within 60
    Regds,
    Shashank

Maybe you are looking for