File Write Adapter, First record as a Column Header

Hi,
Using File adapter of type WRITE i m creating a file.
I want to include the column header also as a first record in File.
One way i can think of Creating one record manually and append as a first record in the File write variable.
Is there any other simple way or standard way to do it??

To have fixed header every time before it writes the data, i think you should have file with header and data, then use it to configure file write in JCA adapter.
This will create a schema with static header and dynamic results to the schema file.
So that everytime you will have the header then it write the data below that.
Note: I have done this some years back, i wrote here with from my memory.
Let me know if you still have problem, wll try to create a simple example and share.
Thanks,
Vijay

Similar Messages

  • 'Add Output Header' option of File Write Adapter

    Hi All,
    Could you please tell what is this option used for :
    'Add Output Header'
    In a File Write Adapter, and how can I test it?
    Thanks.

    To have fixed header every time before it writes the data, i think you should have file with header and data, then use it to configure file write in JCA adapter.
    This will create a schema with static header and dynamic results to the schema file.
    So that everytime you will have the header then it write the data below that.
    Note: I have done this some years back, i wrote here with from my memory.
    Let me know if you still have problem, wll try to create a simple example and share.
    Thanks,
    Vijay

  • Formula to select first record on the column

    Hi All
    I need a formula to select a first record on the column, here is my query
    SELECT DISTINCT
                          dbo.OWOR.DocNum, dbo.OWOR.ItemCode, dbo.OWOR.Status, dbo.OWOR.PlannedQty, dbo.ITM1.Price, dbo.OWOR.Warehouse,
                          dbo.OWOR.PlannedQty * dbo.ITM1.Price AS Total
    FROM         dbo.OWOR INNER JOIN
                          dbo.ITM1 ON dbo.OWOR.ItemCode = dbo.ITM1.ItemCode
    WHERE     (dbo.OWOR.Status = 'P') OR
                          (dbo.OWOR.Status = 'R') AND dbo.ITM1.Price
    I need to select the first price on the price list for (dbo.ITM1.Price).
    Regards
    Bongani

    Bongani,
    Are you sure you don't want to link a pricelist? Because the unique key on ITM1 consists of ItemCode and PriceList and taking the first price for an item in ITM1 could result in kind of random prices for different items, depending on whice pricelist gets filled first for a certain item.

  • Question about pass file name and path to file write adapter

    I need to pass file name and path to file adapter for write. I got partial answers from thread Re: Get File name using File Adapter , but seems InboundHeader_msg or outboundHeader_msg only takes file name, how do I pass file directory?
    since I still have to specify file format (like xxx_%xx%.txt) in the file adapter wizard. Will this name conflict with what the name defined in InboundHeader_msg ?
    Similarly, how can I pass a file name and path to a file synchread adapter?
    Thanks,
    Message was edited by:
    user531689

    Just overwrite the filename in the WSDL file that was generated

  • SXDA split files for RMDATIND - First record in sequential file & not a session record (type 0)

    Hi gurus,
    I'm trying to perform a mass upload of material master records and for this I've have setup a Data Transfer Project in SXDA with the purpose of splitting an LSMW input file into multiple. The file split task is using Data Load Program:
    Object Type: BUS1001006
    Obj. description: AD Standard Material
    Program type: DINP
    Program: RMDATIND
    The problem I'm facing is that once the .conv (Converted Data) is split in multiple files these files are being transferred without a session record. This is causing to get the following error when running program: RMDATIND "First record in sequential file & not a session record (type 0)"
    So the questions is: How can I specify in SXDA that I want to keep that session record in all my split files?
    Thanks in advance for your help!

      Hi Chris ,
    try to re create logical file path/files for converted data.
    regards
    Prabhu

  • File Write Adapter Error

    I am not able to write to a flat file using file adapter. The schema was created using file adapter wizard - 'Define Schema for Native Format'. I tried using a very simple schema with a few fields, but I still got this error.
    I got this error:
    <bindingFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="code"><code>null</code></part><part name="summary"><summary>file:/C:/OraBPELPM_1/integration/orabpel/domains/default/tmp/.bpel_DBAdapterTest_1.0.jar/filewrite2.wsdl [ Write_ptt::Write(Root-Element) ] - WSIF JCA Execute of operation 'Write' failed due to: Translation Error.
    Error while translating message to native format.
    ; nested exception is:
         ORABPEL-11017
    Translation Error.
    Error while translating message to native format.
    Check the error stack and fix the cause of the error. Contact oracle support if error is not fixable.
    </summary></part><part name="detail"><detail>null</detail></part></bindingFault>
    I am using the latest BPEL 10.1.2.0.2.
    I already read another thread (Re: Invoke Write Error which talks about the same error. But it doens't help.
    Please tell me how to debug the problem.
    Thanks,
    Kate

    Not sure if this will help. But before you start trying to write the file have you done a test in the transformation?
    This is done by right click in the middle panel in the transformation process. If the xml generated is invalid then this is your problem.
    cheers
    James

  • Reading UTL_File, first record is missing

    Hi,
    I am reading text file using UTL_FILE to insert data in staging table.For some reason the first record in the text file in not inserting in table
    (suppose there are 10 records in text.file, except very first record rest of the records will be inserted successfully).Please help me on this.
    create or replace
    PROCEDURE PRC_XYZ_FILE_LOAD(
        p_in_file_name IN VARCHAR2,
        p_out_message OUT VARCHAR2)
    IS
    v_membernumber     whr_stageftd.membernumber%TYPE ;
      v_memberfullname   whr_stageftd.memberfullname%TYPE ;
    BEGIN
    --open files
      v_file_handler := UTL_FILE.FOPEN(v_file_path, v_file_name, 'r');
       UTL_FILE.GET_LINE(v_file_handler, v_text);
       LOOP
        BEGIN
             BEGIN
            UTL_FILE.GET_LINE(v_file_handler, v_text);
          EXCEPTION
          WHEN no_data_found THEN
            EXIT; -- end of file
          END;
          -------------------- Insert data in to whr_stageftd table -------------------------------
          v_detail_record              :=FNC_PIPE_PARSE (V_TEXT,1,'~');
           v_membernumber               :=FNC_PIPE_PARSE (V_TEXT,2,'~');
           v_memberfullname             :=FNC_PIPE_PARSE (V_TEXT,3,'~');
           v_stage:='stage3';
           v_locationid                 :=FNC_PIPE_PARSE (V_TEXT,4,'~');
           v_regionid                   :=FNC_PIPE_PARSE (V_TEXT,5,'~');
           v_transstartdate             :=FNC_PIPE_PARSE (V_TEXT,6,'~');
           v_transenddate               :=FNC_PIPE_PARSE (V_TEXT,7,'~');
          IF v_detail_record            = '2' THEN
            INSERT
            INTO whr_stageftd
                fileid ,
                membernumber ,
                memberfullname ,
                locationid,
                regionid,
                earningstartdate,
                earningenddate  )
              VALUES
                v_fileid,
                v_membernumber,
                v_memberfullname,
                v_locationid,
                v_regionid,
                v_transstartdate ,
                v_transenddate);
            v_rec_counter := v_rec_counter + 1;
            IF mod(v_rec_counter,10000)= 0 THEN
              COMMIT;
            END IF;
          END IF;
        EXCEPTION
        WHEN OTHERS THEN
         dbms_output.put_line(Sqlerrm||v_stage);
          END;
      END LOOP;
       COMMIT;
      UTL_FILE.FCLOSE(v_file_handler);
    END PRC_XYZ_FILE_LOAD;here is the code for FNC_PIPE_PARSE
    create or replace
    Function      FNC_PIPE_PARSE
    (p_instring in varchar2,
      p_field_no in number,
      p_delimiter in varchar2 default '|')
      RETURN varchar2 IS
    v_start number;
    v_no_of_chars number;
    v_instring varchar2(4000);
        v_delimiter_length NUMBER(10) := 0;
    BEGIN
    v_delimiter_length := length(p_delimiter);
    v_instring:=p_instring||p_delimiter;
      IF p_field_no = 1 THEN
         return(substr(v_instring,1,instr(v_instring,p_delimiter)-1));
      ELSE
       v_start := instr(v_instring,p_delimiter,1,p_field_no-1)+v_delimiter_length;
       v_no_of_chars := instr(v_instring,p_delimiter,1,p_field_no) - v_start;
    return(substr(v_instring,v_start,v_no_of_chars));
      END IF;
    END; sample data
    actual data
    2~105266648J~C TEST~~~20050707~20050707
    2~104133506D~K TEST~~~20050707~20050707
    2~104929890I~A TEST~~~20050707~20050707
    2~104700166K~D TEST~~~20050708~20050708data inserted in table is (which is missing first record
    2~104133506D~K TEST~~~20050707~20050707
    2~104929890I~A TEST~~~20050707~20050707
    2~104700166K~D TEST~~~20050708~20050708Sqlerrm error is
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small stage3THANKS
    Sandy

    Apparently, you don't specify the len parameter to GET_LINE, and the doc says :
    The GET_LINE len parameter must be a number in the range 1 and 32767. If unspecified, Oracle supplies the default value of max_linesize.The FOPEN max_linesize parameter must be a number in the range 1 and 32767. If unspecified, Oracle supplies a default value of 1024. Could that be the culprit ?You should try to put some debug in your code to see what line content raises the error.

  • To display values  in Column Header

    Hi,
    I wanted to display values from viewobject as a column header in af:table
    <af:column sortProperty="Qty" sortable="false"
    headerText="#{bindings.EmpPartHeader12.hints.Qty.label}"
    headerClass="TableNoHeader"
    inlineStyle="background-color:#D3D3D3; border-color:Gray; color:Black;"
    align="right" id="c1">
    <f:facet name="header">
    <af:outputText value="#{row.Qty}" id="ot8"
    />
    </f:facet>
    <af:outputText value="#{row.Cost}" id="ot4"/>
    </af:column>
    I am using <af:outputText value="#{row.Qty}" id="ot8"/> in header class of af:column but getting blank as column header.
    Please help on this.
    Regards
    Vasu

    Hi user13818315,
    Please specify in details what you want to display in column header ? Say there are 5 rows in your table do you want to display the first rows data as column header ?
    Please explain...
    Thanks
    --NavinK                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • File adapter SyncRead Operation adds "???" to first record of csv file

    Hi All,
    One interface is reading one CSV file (containing two fields only) using SyncRead Operation of File Adapter. But I found, when file adapter parsed the data it appends "???" to first field of the first record which cause further data validation in the process.
    Test.csv file
    123456,159357
    147258,987654
    Trace of the FileAdapter:
    <messages>
    <Invoke_FILE_Inbound_InputVariable>
    <part  name="Empty">
    <empty/>  
    </part>
    </Invoke_FILE_Inbound_InputVariable>
    <Invoke_FILE_Inbound_OutputVariable>
    <part  name="body">
    <Root-Element>
    <TestElements>
    <Emplid>���123456</Emplid>  
    <SupId>159357</SupId>
    </TestElements>
    <HRRespIDElements>
    <Emplid>147258</Emplid>  
    <SupId>987654</SupId>
    </TestElements>
    </Root-Element>
    </part>
    </Invoke_FILE_Inbound_OutputVariable>
    </messages>
    Can anyone help me to understand , what is reason? Or I missed anything.
    Thanks & Regards,
    Sharmistha

    Unfortunately, this is documented bahaviour (solution/workaround anyone?!):
    Elapsed Time Exceeds:
    Specify a time which, when exceeded, causes a new outgoing file to be created.
    Note:
    The Elapsed Time Exceeds batching criteria is evaluated and a new outgoing file is created, only when an invocation happens.
    For example, if you specify that elapsed time exceeds 15 seconds, then the first message that is received is not written out, even after 15 seconds, as batching conditions are not valid. If a second message is received, then batching conditions become valid for the first one, and an output file is created when the elapsed time exceeds 15 seconds.

  • DB Adapter: Polling For New Records returns the First record multiple Times

    I Polling for New or Chnaged Records against DB2 on iSeries. The DB Adapter returns the first record from the Table multiple Times. If the Table has 5 records it displays the first record 5 times. I am using BPEL 10.1.3.1 Can anyone help me with this.

    Hi there,
    please check out the DBAdapter trouble-shooting guide:
    http://download-east.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/app_trblshoot.htm#CIHFEHFA
    I am copying an entry from there into here:
    A.1.21 Some Queried Rows Appear Twice or Not at All in the Query Result
    Problem
    When you execute a query, you may get the correct number of rows, but some rows appear multiple times and others do not appear at all.
    This behavior is typically because the primary key is configured incorrectly. If the database adapter reads two different rows that it thinks are the same (for example, the same primary key), then it writes both rows into the same instance and the first row's values are overwritten by the second row's values.
    Solution
    Open Application Sources > TopLink > TopLink Mappings. In the Structure window, double-click PHONES. On the first page, you should see Primary Keys. Make sure that the correct columns are selected to make a unique constraint.
    Save and then edit the database partner link.
    Click Next to the end, and then click Finish and Close.
    Open your toplink_mappings.xml file. For the PHONES descriptor, you should see something like this:
    <primary-key-fields>
    <field>PHONES.ID1</field>
    <field>PHONES.ID2</field>
    </primary-key-fields>
    Thanks
    Steve

  • File Adapter - Multiple Record Types to same Target

    I am currently reading in a fixed length file and loading into a table.
    The issue is, some of the lines in my file differ by two spaces at the end. See example below.
    For example,
    Record 1 might look like :
    DD/MM/YY - length of 8
    Record 2 might look like:
    DD/MM/YY{space}{space} - length of 10
    and they both go into the same date column of my target
    Question 1) Is there a way for BPEL to skip the two spaces at the end of each line for Record 2
    Queston 2) I have currently created multiple record types for the two types but it won't allow me in my transformation to map them both to the "date" column in the target table. It says multiple nodes cannot be mapped to the target
    Any help would be appreciated.

    Hi,
    Unfortunately the IKM SQLDR doesn't have the "when" condition to be wrote at ctl file.
    If you wish a simple solution, just add an option (drop me a email if you want a LKM with this)
    The point is:
    With a single option, you will control the when ctl clause and, for instance, can define:
    1) create 2 datastores (1 for each file)
    2) the first position will be a column at each datastore
    3) write the when condition to this first column at the LKM in the interface.
    Does it help you?

  • How to skip first record while inserting data from a flat file to BW system

    Hi Experts,
    In my project we have to upload flat file into a BW system. I have written a program and it is working fine.
    Now we have got another requirement. The flat file will have a header record (first row). While uploading the flat file we have to skip this record. How I can do so?
    The code is as below:
    FORM upload1.
      DATA : wf_title    TYPE string,
              lt_filetab  TYPE filetable,
              l_separator TYPE char01,
              l_action    TYPE i,
              l_count     TYPE i,
              ls_filetab  TYPE file_table,
              wf_delemt TYPE rollname,
              wa_fieldcat TYPE lvc_s_fcat,
              tb_fieldcat TYPE lvc_t_fcat,
              rows_read TYPE i,
              p_error   TYPE char01,
              l_file      TYPE string.
      DATA: wf_object(30)  TYPE c,
              wf_tablnm TYPE rsdchkview.
      wf_object = 'myprogram'.
      DATA i TYPE i.
      DATA:
           lr_mdmt                TYPE REF TO cl_rsdmd_mdmt,
           lr_mdmtr               TYPE REF TO cl_rsdmd_mdmtr,
           lt_idocstate           TYPE rsarr_t_idocstate,
           lv_subrc               TYPE sysubrc.
      TYPES : BEGIN OF test_struc,
               /bic/myprogram TYPE  /bic/oimyprogram,
               txtmd   TYPE rstxtmd,
               END OF test_struc.
      DATA :    tb_assum TYPE TABLE OF /bic/pmyprogram.
      DATA: wa_ztext TYPE  /bic/tmyprogram,
            myprogram_temp TYPE ziott_assum,
            wa_myprogram TYPE /bic/pmyprogram.
      DATA : test_upload TYPE STANDARD TABLE OF test_struc,
             wa2 TYPE  test_struc.
      DATA : wa_test_upload TYPE test_struc,
             ztable_data TYPE TABLE OF /bic/pmyprogram,
             ztable_text TYPE TABLE OF /bic/tmyprogram,
             wa_upld_text TYPE /bic/tmyprogram,
             wa_upld_data TYPE /bic/pmyprogram,
              t_assum TYPE ziott_assum.
      DATA : wa1 LIKE  test_upload.
      wf_title = text-026.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title            = wf_title
          default_extension       = 'txt'
          file_filter             = 'Tab delimited Text Files (*.txt)'
        CHANGING
          file_table              = lt_filetab
          rc                      = l_count
          user_action             = l_action
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          OTHERS                  = 3.                          "#EC NOTEXT
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      LOOP AT lt_filetab INTO ls_filetab.
        l_file = ls_filetab.
      ENDLOOP.
      CHECK l_action = 0.
      IF l_file IS INITIAL.
        EXIT.
      ENDIF.
      l_separator = 'X'.
      wa_fieldcat-fieldname = 'test'.
      wa_fieldcat-dd_roll = wf_delemt.
      APPEND wa_fieldcat TO tb_fieldcat.
      CALL FUNCTION 'MESSAGES_INITIALIZE'.
      CLEAR wa_test_upload.
    Upload file from front-end (PC)
    File format is tab-delimited ASCII
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = l_file
          has_field_separator     = l_separator
        TABLES
         data_tab                = i_mara
        data_tab                   = test_upload
        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.
        EXIT.
      ELSE.
       CALL FUNCTION 'MESSAGES_INITIALIZE'.
        IF test_upload IS NOT INITIAL.
          DESCRIBE TABLE test_upload LINES rows_read.
          CLEAR : wa_test_upload,wa_upld_data.
          LOOP AT test_upload INTO wa_test_upload.
            CLEAR :  p_error.
            rows_read = sy-tabix.
            IF wa_test_upload-/bic/myprogram IS INITIAL.
              p_error = 'X'.
              MESSAGE s153 WITH wa_test_upload-/bic/myprogram sy-tabix.
              CONTINUE.
            ELSE.
              TRANSLATE wa_test_upload-/bic/myprogram TO UPPER CASE.
              wa_upld_text-txtmd  = wa_test_upload-txtmd.
              wa_upld_text-txtsh  = wa_test_upload-txtmd.
              wa_upld_text-langu =  sy-langu.
              wa_upld_data-chrt_accts = 'xyz1'.
              wa_upld_data-co_area = '12'.
              wa_upld_data-/bic/zxyzbcsg = 'Iy'.
              wa_upld_data-objvers = 'A'.
              wa_upld_data-changed = 'I'.
              wa_upld_data-/bic/zass_mdl = 'rrr'.
              wa_upld_data-/bic/zass_typ = 'I'.
              wa_upld_data-/bic/zdriver = 'yyy'.
              wa_upld_text-langu = sy-langu.
              MOVE-CORRESPONDING wa_test_upload TO wa_upld_data.
              MOVE-CORRESPONDING wa_test_upload TO wa_upld_text.
              APPEND wa_upld_data TO ztable_data.
              APPEND wa_upld_text TO ztable_text.
            ENDIF.
          ENDLOOP.
          DELETE ADJACENT DUPLICATES FROM ztable_data.
          DELETE ADJACENT DUPLICATES FROM ztable_text.
          IF ztable_data IS NOT INITIAL.
            CALL METHOD cl_rsdmd_mdmt=>factory
              EXPORTING
                i_chabasnm     = 'myprogram'
              IMPORTING
                e_r_mdmt       = lr_mdmt
              EXCEPTIONS
                invalid_iobjnm = 1
                OTHERS         = 2.
       CALL FUNCTION 'MESSAGES_INITIALIZE'.
       **Lock the Infoobject to update
            CALL FUNCTION 'RSDG_IOBJ_ENQUEUE'
              EXPORTING
                i_objnm      = wf_object
                i_scope      = '1'
                i_msgty      = rs_c_error
              EXCEPTIONS
                foreign_lock = 1
                sys_failure  = 2.
            IF sy-subrc = 1.
              MESSAGE i107(zddd_rr) WITH wf_object sy-msgv2.
              EXIT.
            ELSEIF sy-subrc = 2.
              MESSAGE i108(zddd_rr) WITH wf_object.
              EXIT.
            ENDIF.
    *****Update Master Table
            IF ztable_data IS NOT INITIAL.
              CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
                    EXPORTING
                      i_iobjnm                     = 'myprogram'
                      i_tabclass                   = 'M'
           I_T_ATTR                     = lt_attr
                    TABLES
                      i_t_table                    = ztable_data
                      EXCEPTIONS
                     attribute_name_error         = 1
                     iobj_not_found               = 2
                     generate_program_error       = 3
                     OTHERS                       = 4.
              IF sy-subrc <> 0.
                CALL FUNCTION 'MESSAGE_STORE'
                  EXPORTING
                    arbgb  = 'zddd_rr'
                    msgty  = 'E'
                    txtnr  = '054'
                    msgv1  = text-033
                  EXCEPTIONS
                    OTHERS = 3.
                MESSAGE e054(zddd_rr) WITH 'myprogram'.
              ELSE.
                CALL FUNCTION 'MESSAGE_STORE'
                  EXPORTING
                    arbgb  = 'zddd_rr'
                    msgty  = 'S'
                    txtnr  = '053'
                    msgv1  = text-033
                  EXCEPTIONS
                    OTHERS = 3.
              ENDIF.
    *endif.
    *****update Text Table
              IF ztable_text IS NOT INITIAL.
                CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
                  EXPORTING
                    i_iobjnm               = 'myprogram'
                    i_tabclass             = 'T'
                  TABLES
                    i_t_table              = ztable_text
                  EXCEPTIONS
                    attribute_name_error   = 1
                    iobj_not_found         = 2
                    generate_program_error = 3
                    OTHERS                 = 4.
                IF sy-subrc <> 0.
                  CALL FUNCTION 'MESSAGE_STORE'
                    EXPORTING
                      arbgb  = 'zddd_rr'
                      msgty  = 'E'
                      txtnr  = '055'
                      msgv1  = text-033
                    EXCEPTIONS
                      OTHERS = 3.
                ENDIF.
              ENDIF.
            ELSE.
              MESSAGE s178(zddd_rr).
            ENDIF.
          ENDIF.
          COMMIT WORK.
          CALL FUNCTION 'RSD_CHKTAB_GET_FOR_CHA_BAS'
            EXPORTING
              i_chabasnm = 'myprogram'
            IMPORTING
              e_chktab   = wf_tablnm
            EXCEPTIONS
              name_error = 1.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
    ****Release locks on Infoobject
          CALL FUNCTION 'RSDG_IOBJ_DEQUEUE'
            EXPORTING
              i_objnm = 'myprogram'
              i_scope = '1'.
        ENDIF.
      ENDIF.
      PERFORM data_selection .
      PERFORM update_alv_grid_display.
      CALL FUNCTION 'MESSAGES_SHOW'.
    ENDFORM.
    Please let me know how I can skip first record of the flat file?
    Regards,
    S

    go through this hope u can get some idea
    REPORT  ztest no standard page heading line-size 255.
                          Declaration                            *
    TYPES t_itab1 TYPE alsmex_tabline.
    types: begin of t_csks,
           kostl like csks-kostl,
          end of t_csks.
    types: begin of t_cska,
           kstar like cska-kstar,
          end of t_cska.
    data: begin of t_flatfile,
          docdate like COHEADER-BLDAT,
          postdate like COHEADER-BUDAT,
          doctext like COHEADER-BLTXT,
           costele like RK23F-KSTAR,
           amount like RK23F-WTGBTR,
           scostctr like RK23F-SKOSTL,
           rcostctr like RK23F-EKOSTL,
           rintorder like RK23F-EAUFNR,
         end of t_flatfile.
    data: begin of t_flatfile1,
          docdate like COHEADER-BLDAT,
          postdate like COHEADER-BUDAT,
          doctext like COHEADER-BLTXT,
           costele like RK23F-KSTAR,
           amount like RK23F-WTGBTR,
           scostctr like RK23F-SKOSTL,
           rcostctr like RK23F-EKOSTL,
           rintorder like RK23F-EAUFNR,
           NUM LIKE SY-INDEX,
         end of t_flatfile1.
    data: itab like table of t_flatfile with header line.
    data: itab2 like table of t_flatfile1 with header line.
    DATA: it_itab1 TYPE STANDARD TABLE OF t_itab1 WITH HEADER LINE,
          MESSTAB1 LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,
          MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    data: begin of bdcdata occurs 0.
            include structure bdcdata.
    data: end of bdcdata.
    data:t_lin type i VALUE '0',
         u_rec type i VALUE '0',
         s_rec type i VALUE '0'.
    data: it_csks type standard table of t_csks,
          wa_csks type t_csks.
    data: it_cska type standard table of t_cska,
          wa_cska type t_cska.
    *Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME  TITLE text-010.
    parameters: p_docdat  LIKE  COHEADER-BLDAT obligatory,
                p_postda LIKE  COHEADER-BUDAT obligatory,
                p_doctxt  LIKE  COHEADER-BLTXT.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME  TITLE text-011.
    parameters: p_file LIKE RLGRAP-FILENAME obligatory,
                DIS_MODE LIKE CTU_PARAMS-DISMODE DEFAULT 'N'.
    SELECTION-SCREEN END OF BLOCK b2.
                  A T  S E L E C T I O N   S C R E E N                  *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM get_local_file_name USING p_file.
    *Start of Selection
    START-OF-SELECTION.
      Perform get_Excel_data.
      perform validate_data.
      Perform Process_Data.
                    end-of-selection
    end-of-selection.
      perform display_data.
    *&      Form  get_local_file_name
          text
         -->P_P_FILE  text
    FORM get_local_file_name  USING    P_P_FILE.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        CHANGING
          file_name = p_file.
    ENDFORM.                    " get_local_file_name
    *&      Form  get_Excel_data
          text
    -->  p1        text
    <--  p2        text
    FORM get_Excel_data .
      FIELD-SYMBOLS : <FS>.
      DATA : V_INDEX TYPE I.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = 1
        i_begin_row             = 2
          i_begin_row             = 1
          i_end_col               = 256
          i_end_row               = 9999                        "65536
        TABLES
          intern                  = it_itab1
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 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.
        Message text-013 type 'E'.
      ENDIF.
      IF IT_ITAB1[] IS INITIAL.
        Message text-001 type 'E'.
      else.                                    "IF IT_ITAB1[] IS INITIAL.
        data: itab2 like itab occurs 0 with header line.
        SORT IT_ITAB1 BY ROW COL.
        LOOP AT IT_ITAB1.
          MOVE :IT_ITAB1-COL TO V_INDEX.
          ASSIGN COMPONENT V_INDEX OF STRUCTURE itab2 TO  <FS>.
          MOVE : IT_ITAB1-VALUE TO <FS>.
          AT END OF ROW.
            MOVE-CORRESPONDING itab2 TO itab.
            APPEND itab.
            CLEAR:itab,itab2.
          ENDAT.
        endloop.
        describe table itab lines t_lin.
      endif.               "IF IT_ITAB1[] IS INITIAL.
    ENDFORM.                    " get_Excel_data
    *&      Form  Process_Data
          text
    -->  p1        text
    <--  p2        text
    FORM Process_Data .
      data:l_tabix type sy-tabix.
      data:l_periv like t001-periv,
           l_monat like bkpf-monat,
           l_gjahr like bkpf-gjahr,
           l_amt(21) type c.
      data: l_ddate(10),
            l_pdate(10).
      WRITE p_docdat TO l_ddate.
      WRITE p_postda TO l_pdate.
      clear: l_periv,l_monat,l_gjahr.
      select single periv from t001 into l_periv where bukrs = '5000'. "P_bukrs
      if sy-subrc eq 0.
        l_gjahr = p_postda+0(4).
        call function 'FI_PERIOD_DETERMINE'
          EXPORTING
            i_budat = p_postda
            i_bukrs = '5000'     "p_bukrs
            i_periv = l_periv
            i_gjahr = l_gjahr
          IMPORTING
            e_monat = l_monat.
        clear:l_periv.
      endif.
      loop at itab2.
        refresh:bdcdata.
        clear:bdcdata.
        l_tabix = sy-tabix.
        perform bdc_dynpro      using 'SAPLK23F1' '1200'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '/00'.
        perform bdc_field       using 'COHEADER-SEND_REC_REL'
                                      '10SAP'.
        perform bdc_field       using 'RK23F-STATUS'
                                      'S'.
        perform bdc_field       using 'COHEADER-BLDAT'
                                 itab-docdate.
                                      l_ddate.
        perform bdc_field       using 'COHEADER-BUDAT'
                                 itab-postdate.
                                      l_pdate.
        perform bdc_field       using 'COHEADER-PERIO'
                                       l_monat.                 "'9'.
        perform bdc_field       using 'COHEADER-BLTXT'
                                 itab-doctext.
                                      p_doctxt.
        perform bdc_field       using 'RK23F-KSTAR'
                                      itab2-costele.
        WRITE itab2-amount TO l_amt.
    l_amt = itab-amount.
        condense l_amt no-gaps.
        perform bdc_field       using 'RK23F-WTGBTR'
                                       l_amt.
                                 itab-amount.
        perform bdc_field       using 'RK23F-WAERS'
                                      'USD'.
    *perform bdc_field       using 'RK23F-SGTXT'
                                 itab-doctext.
        perform bdc_field       using 'RK23F-SKOSTL'
                                      itab2-scostctr.
        perform bdc_field       using 'BDC_CURSOR'
                                      'RK23F-EAUFNR'.
        perform bdc_field       using 'RK23F-EKOSTL'
                                      itab2-rcostctr.
        perform bdc_field       using 'RK23F-EAUFNR'
                                      itab2-rintorder.
        perform bdc_dynpro      using 'SAPLK23F1' '1200'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=POST'.
        perform bdc_field       using 'COHEADER-SEND_REC_REL'
                                      '10SAP'.
        perform bdc_field       using 'RK23F-STATUS'
                                      'S'.
        perform bdc_field       using 'COHEADER-BLDAT'
                                 itab-docdate.
                                      l_ddate.
        perform bdc_field       using 'COHEADER-BUDAT'
                                  itab-postdate.
                                      l_pdate.
        perform bdc_field       using 'COHEADER-PERIO'
                                 '9'.
                                        l_monat.
        perform bdc_field       using 'COHEADER-BLTXT'
                                  itab-doctext.
                                      p_doctxt.
        perform bdc_field       using 'BDC_CURSOR'
                                      'RK23F-KSTAR'.
        perform bdc_field       using 'RK23F-WAERS'
                                      'USD'.
        CALL TRANSACTION 'KB15N' USING BDCDATA MODE DIS_MODE MESSAGES INTO MESSTAB.
        If sy-subrc = 0.
          s_rec = s_rec + 1.
        ELSE.
          u_rec = u_rec + 1.
          move ITAB2-NUM to messtab1-msgv1.
          concatenate itab2-costele ' | ' itab2-scostctr  ' | '  itab2-rcostctr ' | ' itab2-rintorder  into  messtab1-msgv2.
          condense messtab1-msgv2.
          condense messtab1-msgv1.
          append messtab1.
        endif.
        clear:itab2.
      endloop.
    ENDFORM.                    " Process_Data
          BDC_DYNPRO                                                     *
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDCDATA.
      BDCDATA-PROGRAM  = PROGRAM.
      BDCDATA-DYNPRO   = DYNPRO.
      BDCDATA-DYNBEGIN = 'X'.
      APPEND BDCDATA.
    ENDFORM.                    "BDC_DYNPRO
           BDC_FIELD                                                     *
    FORM BDC_FIELD USING FNAM FVAL.
      IF FVAL <> ''. "NODATA.
        CLEAR BDCDATA.
        BDCDATA-FNAM = FNAM.
        BDCDATA-FVAL = FVAL.
        APPEND BDCDATA.
      ENDIF.
    ENDFORM.                    "BDC_FIELD
    *&      Form  display_data
          text
    -->  p1        text
    <--  p2        text
    FORM display_data .
      skip 2.
      write:/15 text-002.
      skip 2.
      write:/8 text-003.
      SKIP.
      write:/12 text-008,
             25 P_DOCDAT.
      SKIP.
      write:/12 text-009,
             25 P_POSTDA.
      SKIP.
      write:/12 text-012,
              25 P_DOCTXT.
      SKIP.
      write:/12 text-004,
             25 p_file.
      skip 2.
      write:/8 text-005,
            60 t_lin.
      skip.
      write:/8 text-006,
            60 s_rec.
      skip.
      write:/8 text-007,
            60 u_rec.
      skip.
      write:/10 'row no',
             20 'Information'.
      skip.
      loop at messtab1.
        write:/10 messtab1-msgv1,
               20 messtab1-msgv2.
        clear:messtab1.
      endloop.
    ENDFORM.                    " display_data
    *&      Form  validate_data
          text
    -->  p1        text
    <--  p2        text
    FORM validate_data .
      data: l_tabix1 type sy-tabix.
    data: l_tabix2 type sy-tabix.
      if not itab[] is initial.
        select kostl from CSKS into table it_csks.
        if sy-subrc eq 0.
          sort it_csks by kostl.
        endif.
        select kstar from CSKA into table it_cska.
        if sy-subrc eq 0.
          sort it_cska by kstar.
        endif.
        loop at itab.
          l_tabix1 = sy-tabix.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = itab-scostctr
    IMPORTING
       OUTPUT        = itab-scostctr .
          read table it_csks into wa_csks with key kostl = itab-scostctr.
          if sy-subrc ne 0.
            u_rec = u_rec + 1.
           L_TABIX2 = l_tabix1 + 1.
           move l_tabix2 to messtab1-msgv1.
            move l_tabix1 to messtab1-msgv1.
            move itab-rintorder to messtab1-msgv2.
            concatenate itab-costele  ' | ' itab-scostctr  ' | '  itab-rcostctr  ' | ' itab-rintorder  into  messtab1-msgv2.
            condense messtab1-msgv2.
            condense messtab1-msgv1.
            append messtab1.
            clear:wa_csks.
           CLEAR:L_TABIX2.
            continue.
          endif.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = itab-rcostctr
    IMPORTING
       OUTPUT        = itab-rcostctr .
          read table it_csks into wa_csks with key kostl = itab-rcostctr.
          if sy-subrc ne 0.
            u_rec = u_rec + 1.
           L_TABIX2 = l_tabix1 + 1.
           move l_tabix2 to messtab1-msgv1.
            move l_tabix1 to messtab1-msgv1.
              concatenate itab-costele ' | ' itab-scostctr  ' | '  itab-rcostctr ' | ' itab-rintorder  into  messtab1-msgv2.
            condense messtab1-msgv2.
            condense messtab1-msgv1.
            append messtab1.
            clear:wa_csks.
           CLEAR:L_TABIX2.
            continue.
          endif.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = itab-costele
    IMPORTING
       OUTPUT        = itab-costele .
          read table it_cska into wa_cska with key kstar = itab-costele.
          if sy-subrc ne 0.
            u_rec = u_rec + 1.
           L_TABIX2 = l_tabix1 + 1.
           move l_tabix2 to messtab1-msgv1.
            move l_tabix1 to messtab1-msgv1.
            concatenate itab-costele ' | ' itab-scostctr  ' | '  itab-rcostctr ' | ' itab-rintorder  into  messtab1-msgv2.
            condense messtab1-msgv2.
            condense messtab1-msgv1.
            append messtab1.
            clear:wa_csks.
           CLEAR:L_TABIX2.
            continue.
          endif.
    move-corresponding itab to itab2.
    MOVE l_tabix1  TO ITAB2-NUM.
    append itab2.
    clear: itab2.
          clear:itab.
        endloop.
      else.
        message 'No records in File'  type 'S'.
      endif.
    ENDFORM.                    " validate_data

  • File Sender adapter not reading the first line

    Hi,
    I have a scenario configured from file to jdbc adapter.
    However, I found a problem in my file sender adapter. My file adpater always not picking up the first line from my text even I have set the 'Document Offset' to 0.
    Any Ideas? Thanks.
    Regards,
    Pua

    Hi Latika Sethi,
    My complete input text file is as below, it contains only 2 testing records:-
    H1|DIZ1                          |A0016507    |10000020|09/2007
    H2|ABC0001
    D|P|0001|Gaji Pokok       |   1,000.09
    D|D|0002|Denda              |   1,000.00
    D|P|0003|Elaun               |   1,000.00
    H1|PUA1                        |A0016508    |10000021|09/2007
    H2|ABC0002
    D|P|0001|Gaji Pokok       |   2,744.09
    D|D|0002|Denda              |   2,000.00
    D|P|0003|Elaun               |   2,000.00
    After the message mapping, I found the pipeline existed in sxmb_moni as below:-
    <?xml version="1.0" encoding="utf-8"?>
    <ns:mt_rmp03B_filejdbc_sender xmlns:ns="urn:rmp03:pdrm:ips:jdbcjdbc">
    <PaySlip>
    ..<Header2>
    .... <IC>ABC0001</IC>
    .. </Header2>
    .. <Details>
    .... <Jenis>P</Jenis>
    .... <No>0001</No>
    .... <Deskripsi>Gaji Pokok</Deskripsi>
    .... <Jumlah>1,000.09</Jumlah>
    .. </Details>
    </PaySlip>
    <PaySlip>
    .. <Header1>
    .... <Nama>PUA1</Nama>
    .... <KWSP>A0016508</KWSP>
    .... <NoGaji>10000021</NoGaji>
    .... <Bulan>09/2007</Bulan>
    .. </Header1>
    .. <Header2>
    .... <IC>ABC0002</IC>
    .. </Header2>
    .. <Details>
    .... <Jenis>P</Jenis>
    .... <No>0001</No>
    .... <Deskripsi>Gaji Pokok</Deskripsi>
    .... <Jumlah>2,744.09</Jumlah>
    .. </Details>
    </Payslip>
    There are 2 payslips as for the top payslip node...Header1 tag is missing. It means that during the file sender step....the first line of my record which is :-
    "H1|DIZ1                          |A0016507    |10000020|09/2007"
    is not read into the xi pipeline. Basically this is the problem i faced.
    Has somebody facing the same problem before? Currently I have no choice but moved the First line of the text into Second line and left the first line of the text become null/ empty line. As such both records can be successfully read by the XI.
    However what I wondered is sometimes clients will do insert the records into the first line and this might made some data loss.
    Thanks...

  • Supress Column Heading - File Content Conversion in Sender Adapter

    Hi,
    Let me give a more clear picture about my scenario.  I need to convert CSV File to XML output:-
    My source file has column heading and values.  The sample data is mentioned hereunder:-
    PERNR;KID;PNALT;NACHN;NAME2;VORNA
    ;1200;1200;Angus
    I have created a data type as under:-
    DT_LegacyEmployee (Category - Complex Type)
         Employees (Category - Element, Occurence - 1)
              Header (Category - Element, Occurence - 0...1)
                   PERNR_H
                   KID_H
                   PNALT_H
                   NACHN_H
                   NAME2_H
                   VORNA_H
              Employee (Categroy - Element, Type - DT_LegacyEmployee_Row, Occurence - 0...unbounded)
                   PERNR
                   KID
                   PNALT
                   NACHN
                   NAME2
                   VORNA
    The file conversion parameters in the file sender adapter are mentioned hereunder:-
    Document Name - MT_LegacyEmployee
    Document Namespace - http://abc.com/xi
    Recordset Name - Employees
    Rescordset Structure - Header,1,Employee,*
    Recordsets per Message - 1
    Key Field Type - String (Case Sensitive)
    Employee.fieldSeparator - ;
    Employee.endSeparator - 'nl'
    Employee.fieldNames - PERNR,KID,PNALT,NACHN,NAME2,VORNA
    I dont' have a key field value.  How do we remove the header and show only the values in the xml output.  I have searched the forum topics as well checked many blogs related to file content conversion, but nothing helped.  Kindly advice how to fix this issue.  Thanks in advance.
    Regards.
    Praveen

    Hi Praveen,
    Change your File Adapter as below
    Document Name - MT_LegacyEmployee
    Document Namespace - http://abc.com/xi
    Recordset Name - Employees
    Rescordset Structure - Employee,*
    Recordsets per Message - 1
    Key Field Type - String (Case Sensitive)
    Employee.fieldSeparator - ;
    Employee.endSeparator - 'nl'
    Employee.fieldNames - PERNR,KID,PNALT,NACHN,NAME2,VORNA
    There is no need for the Header required in the data type.
    DT_LegacyEmployee (Category - Complex Type)
    Employees (Category - Element, Occurence - 1)
    Employee (Categroy - Element, Type - DT_LegacyEmployee_Row, Occurence - 0...unbounded)
    PERNR
    KID
    PNALT
    NACHN
    NAME2
    VORNA
    Now the trick is in the mapping program
    Lets assume your mapping looks like
    MT_LegacyEmployee ---> MT_TargetEmployee
    - Employees ---> Records
       - Employee ---> Record
         - PERNR  ---> TargetPERNR
         - .. so on
    When you do a mapping from Employee ---> Record apply the following logic.
    (PERNR)--->
                 (TestEquals =) --->(NOT)--->
    (Constant) --->                                (IF)
    (PERNR)                       (IF Without Else) ---> (Record)
                                                   (THEN)
                                (Employee)--->
    When doing this make sure RightClick on PERNR and Select Context ---> Employees.
    By default context would be from Employee and it will give you an error of XSD format. So make sure you are changing the context.

  • How to skip first records while reading a csv file

    Hi,
    How to skip the first 5 records while reading csv file.
    I have a file which contains first 5 records as dummy records, I want to skip those records and load the rest into RDBMS.
    How to achieve this?
    Thanks,
    Naveen Suram

    Hi Guru,
    Actually I have converted an excel to CSV format, which is generating first 4 rows as some dummy records. 5th row is my header record. But in hearder record, two column names are same. Thats why while reversing it is giving an error.
    With zero in number of columns in header, I am getting the column names as C1, C2...
    If not in reversing, can we reject the first records while loading into RDMBS table using an interface?
    Thanks,
    Naveen Suram

Maybe you are looking for