Problem in processing internal table

Hi All,
Im facing some problem with an internal table with header.
This is Xvbkd with heaer line.
Header     100     0000000049     000010                         EXW     China
1     100     0000000049     000000                         CIF     HK
2     100     0000000049     000010                         CIF     HK
3     100     0000000049     000020                         CIF     HK
Now I want modify the internal table of 2nd record. The data above has modified in the header.but not reflected in the body.
Here is my code:
SELECT SINGLE inco1 inco2
                        INTO (knvv-inco1, knvv-inco2)
                        FROM knvv
                        WHERE kunnr EQ w_shipto
                          AND vkorg EQ vbak-vkorg
                          AND vtweg EQ vbak-vtweg
                          AND spart EQ vbak-spart.
                    IF sy-subrc EQ 0 AND
                        knvv-inco1 NE space or
                        knvv-inco2 NE space.
                      MOVE: knvv-inco1 TO wa_xvbkd-inco1,
                            knvv-inco2 TO wa_xvbkd-inco2.
                     READ table xvbkd with key vbeln = xvbap-vbeln
                                                posnr = xvbap-posnr.
                      IF sy-subrc = 0.
                      xvbkd-inco1 = wa_xvbkd-inco1.
                      xvbkd-inco2 = wa_xvbkd-inco2.
                      modify table xvbkd from wa_xvbkd transporting  inco1 inco2.
                     endif.
                    ENDIF.
Requirement: is the 2nd record(item 10) in above internal table has to reflect the change with EXW and China.
Pls help me with ur valuable suggestions.
Regards,
Priya

try,
SELECT SINGLE inco1 inco2
                        INTO (knvv-inco1, knvv-inco2)
                        FROM knvv
                        WHERE kunnr EQ w_shipto
                          AND vkorg EQ vbak-vkorg
                          AND vtweg EQ vbak-vtweg
                          AND spart EQ vbak-spart.
                    IF sy-subrc EQ 0 AND
                        knvv-inco1 NE space or
                        knvv-inco2 NE space.
                      MOVE: knvv-inco1 TO xvbkd-inco1,
                            knvv-inco2 TO xvbkd-inco2.
                     READ table xvbkd with key vbeln = xvbap-vbeln
                                                posnr = xvbap-posnr.
                      IF sy-subrc = 0.
                      modify xvbkd index sy-tabix.
                     endif.
                    ENDIF.
Regards,
John
Edited by: jvanpelt on Jul 16, 2010 9:36 AM

Similar Messages

  • Problem while processing internal table

    Hi ,
    I have to read 2 line item of same invoice no
    for  eg.
    IN_NO      !    MAT          !      AMT
    XYZ         !    MAT1       !     125
    XYZ         !     MAT2       !     325
    In o/p its display only 325 for both line items
    I used this statement for readiing..
    loop at i_final
    loop at i_itab1 where knumv = i_final-knumv.
           move i_itab1-kwert to i_vbtab-comm .
           clear i_itab1-kwert.
           endloop.
    endloop.
    In debuging i have determine that both first line item
    amt is coming in header line but while coming in body.
    I become the second line item amt
    Can any one help me

    You still are not MODIFYing the table if you intend to write it later
    loop at i_final
      loop at i_itab1 where knumv = i_final-knumv.
        move i_itab1-kwert to i_final-comm .
    *   clear i_itab1-kwert.  "<== No need for this at all
      endloop.
    endloop.
    Additionally, you're moving to your primary loop table.  Never going to see two for it unless you write to a 3rd table or
    replace the CLEAR with a WRITE:/ .......
    Edited by: Paul Chapman on May 14, 2008 10:35 AM

  • Problem while exporting internal table to memory id using EXPORT

    Hi friends,
    Iam facing a following problem.
    I have 4 line items in my va01 tcode.
    now when i give material number and quantity and hit enter the processing for that line item starts.
    iam moving that current line item to a internal table lt_vbap in userexit_check_vbap.
    now for the 2nd line item also i have to move to internal table lt_vbap.
    but my problem is that in internal table lt_vbap iam not getting all the line items.
    every time the current line item is being processed the the previous line items are being refreshed.
    from lt_vbap internal table.
    how can i export internal table.
    code
    move vbap to lt_vbap.
    append lt_vbap.
    export lt_vbap to memory id 'ZXYZ'.

    >
    Prakash Pandey wrote:
    > Hi Priyanka,
    >
    > The internal table lt_vbap will always be empty unless you import it from the Memory ID (in your case ZXYX).
    >
    > Use the code this way:
    >
    > IMPORT lt_vbap FROM MEMORY ID 'ZXYX'.
    >
    > move vbap to lt_vbap.
    >
    > append lt_vbap.
    >
    > export lt_vbap to memory id 'ZXYZ'.
    >
    > Regards,
    > Prakash Pandey
    The memory id shud be same in both cases

  • Need help in processing internal table

    Hi all,
    Im facing a  problem in processing an internal table..especially with MODIFY.
    The internal table is having following records.(t_vttp)
    TKNUM       VBELN      KUNNR       NAME1                             LAND1
    0000975179|0071004839|0000022946|HUNTSMAN APC LIMITED               |SA   |
    0000975180|0071004845|0000022946|                                   |     |
    In the above, there are two delviry documents with same customers.
    The customer data is coming from different internal table.
      LOOP AT t_vttp.
        READ TABLE t_kna1_temp INTO wa_kna1_temp WITH KEY kunnr = t_vttp-kunnr.
        IF sy-subrc = 0.
          t_vttp-name1 = wa_kna1_temp-name1.
          t_vttp-land1 = wa_kna1_temp-land1.
          MODIFY t_vttp INDEX sy-tabix TRANSPORTING name1 land1.
        ENDIF.
      ENDLOOP.
    Here for second record,,the customer name and country is nt getting populated to t_vttop.
    Pls correct where it is going wrong.
    Thanks,
    Priya

    Hi Try the follwoing code with a little modification in your code.
    LOOP AT t_vttp.
    READ TABLE t_kna1_temp INTO wa_kna1_temp WITH KEY kunnr = t_vttp-kunnr.
    IF sy-subrc = 0.
    t_vttp-name1 = wa_kna1_temp-name1.
    t_vttp-land1 = wa_kna1_temp-land1.
    MODIFY t_vttp INDEX sy-tabix  TRANSPORTING name1 land1.
    append t_vttp.
    ENDIF.
    clear: wa_kna1_temp, t_vttp.
    ENDLOOP
    Also Please debugg your code and check if you are getting values.
    also check the value of t_vttp-kunnr in debugging for the second run of your loop.
    thanks
    lalit

  • Problem populating an internal table

    Hello,
    I am having a problem with filling an internal table. I cannot seem to grasp this and I struggle with this in every program. I am attaching pieces of my program so that maybe someone can help me. I have a selection screen that I populate with dates. if the dates are populated, I want to use these dates for the selection. If the dates are initial, I want to read an entry from the TVARV table and populate the dates that will used in the selection. I tried various code statements and I cannot get it to work. i get messages like "is a table without a header line and therefore has no component "LOW" or other messages similar to this. I would like that if the s_udate is populated, I could fill the tvarv table and not have to call the form.
    also if anyone has some documentation on working with internal tables without header lines (I think I read in here that internal tables without header lines is the way to go ), could you please include that as well so that I could try to understand how this suppose to work 
    thanks in advance for the help
    TYPES: BEGIN OF ty_tvarv_date,
            low     TYPE   tvarv_val,          "start date
            high    TYPE   tvarv_val,          "end date
           END OF ty_tvarv_date.
    TYPES: ty_t_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date INITIAL SIZE 0,
    DATA   it_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date INITIAL SIZE 0.
    SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(22) text-002.
    SELECT-OPTIONS s_udate FOR sy-datlo.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK a.
    PERFORM select_date_tvarv CHANGING it_tvarv_date.
    PERFORM select_data643_mseg USING    it_tvarv_date
                                         it_zfi_gl_subcontrk[]
                                  CHANGING it_mseg643.
    <b>*******************************************************************</b>
    FORM select_date_tvarv CHANGING p1_it_tvarv_date TYPE ty_t_tvarv_date.
    IF s_udate IS INITIAL.
      SELECT low high
        FROM tvarv
        INTO  TABLE p1_it_tvarv_date
        WHERE name EQ  'Z_SUBCONTRK_DATES'.
      IF sy-subrc NE 0.
        IF sy-batch IS INITIAL.
          MESSAGE i899 WITH text-027.
          LEAVE LIST-PROCESSING.
        ELSE.
          MESSAGE e899 WITH text-027.
        ENDIF.
      ENDIF.
    ELSE.
         MOVE s_udate to p1_it_tvarv_date.
         MOVE s_udate-low(8)  to p1_it_tvarv_date-low.
         MOVE s_udate-high(8) to p1_it_tvarv_date-high.
    ENDIF.
    ENDFORM. " FORM SELECT_DATE_TVARV
    <b>*******************************************************************</b>
    FORM select_data643_mseg USING p1_tvarv_date       TYPE ty_t_tvarv_date
                                   p1_zfi_gl_subcontrk TYPE ty_t_zfi_gl_subcontrk
                          CHANGING p1_it_mseg          TYPE ty_t_mseg643.
      DATA: wa_tvarv_date type ty_tvarv_date.
      READ TABLE p1_tvarv_date INTO wa_tvarv_date INDEX 1.
      SELECT abukrs  awerks amatnr aerfmg a~erfme
             akostl abwart amblnr awempf acharg akzbew algort bbudat
        FROM mseg AS a INNER JOIN mkpf AS b ON amblnr EQ bmblnr
          AND b~budat <= wa_tvarv_date-high
          AND b~budat >= wa_tvarv_date-low
            INTO TABLE p1_it_mseg
            FOR ALL ENTRIES IN p1_zfi_gl_subcontrk
            WHERE a~bukrs   EQ p1_zfi_gl_subcontrk-bukrs_from
            AND   a~werks   EQ p1_zfi_gl_subcontrk-werks_from
            AND   a~wempf   EQ p1_zfi_gl_subcontrk-werks_to643
            AND   a~matnr   EQ p1_zfi_gl_subcontrk-matnr
            AND   a~bwart   EQ'643'.
      IF sy-subrc NE 0.
        IF sy-batch IS INITIAL.
          MESSAGE i899 WITH text-027.
          LEAVE LIST-PROCESSING.
        ELSE.
          MESSAGE e899 WITH text-027.
        ENDIF.
      ENDIF.
    ENDFORM. " FORM SELECT_DATA643_MSEG

    In tables with header line, you need not define an explicit work area.
    System will create a so-called work area, which is called header line.
    This header line is like any other work area. the difference is that it can be accessed using internal table name. A record will be by default read into header line in a READ statement.
    For ex,
    READ TABLE p1_tvarv_date INTO wa_tvarv_date INDEX 1.
    Here you used to read the 1st record into wa_tvarv_date.
    But after making it table with header line you can use
    READ TABLE p1_tvarv_date INDEX 1.
    This will move the data to header line and it can be accessed by name p1_tvarv_date.
    See the code below.
    TYPES: BEGIN OF ty_tvarv_date,
    low TYPE tvarv_val, "start date
    high TYPE tvarv_val, "end date
    END OF ty_tvarv_date.
    TYPES: ty_t_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date INITIAL SIZE 0,
    DATA it_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date <b>WITH HEADER LINE INITIAL</b> SIZE 0.
    SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(22) text-002.
    SELECT-OPTIONS s_udate FOR sy-datlo.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK a.
    PERFORM select_date_tvarv CHANGING it_tvarv_date.
    PERFORM select_data643_mseg USING it_tvarv_date
    it_zfi_gl_subcontrk[]
    CHANGING it_mseg643.
    FORM select_date_tvarv CHANGING p1_it_tvarv_date TYPE ty_t_tvarv_date.
    IF s_udate IS INITIAL.
    SELECT low high
    FROM tvarv
    INTO TABLE p1_it_tvarv_date
    WHERE name EQ 'Z_SUBCONTRK_DATES'.
    IF sy-subrc NE 0.
    IF sy-batch IS INITIAL.
    MESSAGE i899 WITH text-027.
    LEAVE LIST-PROCESSING.
    ELSE.
    MESSAGE e899 WITH text-027.
    ENDIF.
    ENDIF.
    ELSE.
    MOVE s_udate to p1_it_tvarv_date.
    MOVE s_udate-low(8) to p1_it_tvarv_date-low.
    MOVE s_udate-high(8) to p1_it_tvarv_date-high.
    ENDIF.
    ENDFORM. " FORM SELECT_DATE_TVARV
    FORM select_data643_mseg USING p1_tvarv_date TYPE ty_t_tvarv_date
    p1_zfi_gl_subcontrk TYPE ty_t_zfi_gl_subcontrk
    CHANGING p1_it_mseg TYPE ty_t_mseg643.
    <b>READ TABLE p1_tvarv_date INDEX 1.</b>
    SELECT abukrs awerks amatnr aerfmg a~erfme
    akostl abwart amblnr awempf acharg akzbew algort bbudat
    FROM mseg AS a INNER JOIN mkpf AS b ON amblnr EQ bmblnr
    <b>AND b~budat <= p1_tvarv_date-high
    AND b~budat >= p1_tvarv_date-low</b>
    INTO TABLE p1_it_mseg
    FOR ALL ENTRIES IN p1_zfi_gl_subcontrk
    WHERE a~bukrs EQ p1_zfi_gl_subcontrk-bukrs_from
    AND a~werks EQ p1_zfi_gl_subcontrk-werks_from
    AND a~wempf EQ p1_zfi_gl_subcontrk-werks_to643
    AND a~matnr EQ p1_zfi_gl_subcontrk-matnr
    AND a~bwart EQ'643'.
    IF sy-subrc NE 0.
    IF sy-batch IS INITIAL.
    MESSAGE i899 WITH text-027.
    LEAVE LIST-PROCESSING.
    ELSE.
    MESSAGE e899 WITH text-027.
    ENDIF.
    ENDIF.
    ENDFORM. " FORM SELECT_DATA643_MSEG

  • Problem in returning internal table from FM in ABAP Objects

    Hi All,
    I have to return an internal table from one of the FM i created in the controller class (_IMPL) of a view.
    The problem here is, the internal table i m getting here
    is of type to a structure!.
    but i have to return it as type ref to DATA, which cant be assigned directly.
    Now, my question is.. How can i convert ..
    internal table type structure
    to
    internal table type ref to DATA.
    Thanks and Regards,
    sudeep v d.

    Hi Sudeep.
    Can you see if something like this works for you?
    DATA: dref type ref to DATA.
    FIELD-SYMBOL: <fs> type ANY.
    LOOP AT <internaltable> INTO <structure>
    ASSIGN "<component_name>" component of <structure> TO <fs>
    CREATE DATA dref type <structure>.
    dref->* = <fs>.
    ENDLOOP.

  • Problem in displaying internal table contents to excel(color)

    Hello Gurus!!!!!
    The code is given below :-
    *& Module pool       ZDEMO_DOWNLD1
    PROGRAM  ZDEMO_DOWNLD1.
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
    DATA : f_name(120) type c,
           f_name1(120) type c.
    case sy-ucomm.
    when 'ATTACH'.
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
       DEF_FILENAME           = ' '
      DEF_PATH               = ' '
      MASK                   = ' '
      MODE                   = ' '
      TITLE                  = ' '
    IMPORTING
       FILENAME               = f_name
      RC                     =
    EXCEPTIONS
      INV_WINSYS             = 1
      NO_BATCH               = 2
      SELECTION_CANCEL       = 3
      SELECTION_ERROR        = 4
      OTHERS                 = 5
    *f_name = DEF_FILENAME.
    f_name1 = f_name.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    endcase.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    type-pools ole2.
    data: h_excel type ole2_object, " Excel object
    h_mapl type ole2_object, " list of workbooks
    h_map type ole2_object, " workbook
    h_zl type ole2_object, " cell
    h_f type ole2_object, " font
    h_interior type ole2_object. " Color
    *tables: spfli.
    DATA: ls_emp TYPE zpm_emp_det,
           lt_emp TYPE zpm_emp_det OCCURS 0,
           l_projectname TYPE zpm_emp_item_det-project_name,
           l_projectname_last TYPE zpm_emp_item_det-project_name,
           l_empid TYPE zpm_emp_item_det-empid,
           l_empid_last TYPE zpm_emp_item_det-empid.
    DATA: l_projectname_key TYPE lvc_nkey,
          l_role_of_emp_key TYPE lvc_nkey,
          l_last_key TYPE lvc_nkey.
    DATA :  lt_project_main TYPE TABLE OF zsach_pm ,
            ls_project_main TYPE zsach_pm,
            lt_project TYPE zsach_pm OCCURS 0,
            ls_project TYPE zsach_pm.
    internal table for excel headings
    DATA : BEGIN OF lt_project_ex OCCURS 0,
             line(50) TYPE c,
           END OF lt_project_ex.
    DATA: lt_project1 TYPE zsach_pm OCCURS 0,
          ls_project1 TYPE zsach_pm.
    DATA :   lt_project_temp TYPE zsach_pm OCCURS 0 ,
             ls_project_temp TYPE zsach_pm.
    DATA: lt_project2 TYPE zsach_pm OCCURS 0,
          ls_project2 TYPE zsach_pm.
    TYPES: BEGIN OF st_username,
           username TYPE zuser_names-username,
           END OF st_username.
    DATA: it_tab TYPE TABLE OF st_username,
          wa_tab TYPE st_username.
    data : lt_project_excel like zsach_pm occurs 0 with header line.
    *DATA: f_name TYPE string.
    data h type i.
    table of flights
    data: it_spfli like spfli occurs 10 with header line.
    *& Event START-OF-SELECTION
        SELECT empid
               project_name
               role_of_emp
               competancy
               manager
               price_category
               rate_per_hour
               first_day_pro
               last_day_pro
               ckey
         FROM zpm_emp_item_det
         INTO CORRESPONDING FIELDS OF TABLE lt_project.
        LOOP AT lt_project INTO ls_project.
        ENDLOOP.
        SELECT projectid project_name client begin_date end_date
          FROM zpm_project_det
          INTO CORRESPONDING FIELDS OF TABLE lt_project_temp FOR ALL ENTRIES IN lt_project
          WHERE project_name = lt_project-project_name.
        LOOP AT lt_project_temp INTO ls_project_temp.
          MODIFY lt_project FROM ls_project_temp TRANSPORTING
            projectid project_name client begin_date end_date
            WHERE project_name = ls_project_temp-project_name.
        ENDLOOP.
        SELECT empid
               employee_name
               designation
               employee_type
               date_of_joining
        FROM zpm_emp_head_det
        INTO CORRESPONDING FIELDS OF TABLE lt_project1 FOR ALL ENTRIES IN lt_project
        WHERE empid = lt_project-empid.
        LOOP AT lt_project1 INTO ls_project1.
          MODIFY lt_project FROM ls_project1 TRANSPORTING
                empid
                employee_name
                designation
                employee_type
                date_of_joining
             WHERE empid = ls_project1-empid.
        ENDLOOP.
    tell user what is going on
    call function 'SAPGUI_PROGRESS_INDICATOR'
    exporting
    PERCENTAGE = 0
    text = text-007
    exceptions
    others = 1.
    start Excel
    create object h_excel 'EXCEL.APPLICATION'.
    perform err_hdl.
    set property of h_excel 'Visible' = 1.
    perform err_hdl.
    tell user what is going on
    call function 'SAPGUI_PROGRESS_INDICATOR'
    exporting
    PERCENTAGE = 0
    text = text-008
    exceptions
    others = 1.
    get list of workbooks, initially empty
    call method of h_excel 'Workbooks' = h_mapl.
    perform err_hdl.
    add a new workbook
    call method of h_mapl 'Add' = h_map.
    perform err_hdl.
    tell user what is going on
    call function 'SAPGUI_PROGRESS_INDICATOR'
    exporting
    PERCENTAGE = 0
    text = text-009
    exceptions
    others = 1.
    output column headings to active Excel sheet
    perform fill_cell using 1 1 1 'Project ID'(001).
    perform fill_cell using 1 2 1 'Emp ID'(002).
    perform fill_cell using 1 3 1 'Project Name'(003).
    perform fill_cell using 1 4 1 'Client'(004).
    perform fill_cell using 1 5 1 'Begin Date'(005).
    perform fill_cell using 1 6 1 'End Date'(006).
    perform fill_cell using 1 7 1 'Role of Employee'(007).
    perform fill_cell using 1 8 1 'Module / Competancy'(008).
    perform fill_cell using 1 9 1 'Employee name'(009).
    perform fill_cell using 1 10 1 'Price Category'(010).
    perform fill_cell using 1 11 1 'Rate P/H'(011).
    perform fill_cell using 1 12 1 '1st day in project'(012).
    perform fill_cell using 1 13 1 'Last day in project'(013).
    perform fill_cell using 1 14 1 'Currency'(014).
    perform fill_cell using 1 15 1 'Manager'(015).
    perform fill_cell using 1 16 1 'Emp Type'(016).
    perform fill_cell using 1 17 1 'Designation'(017).
    perform fill_cell using 1 18 1 'Joining Date'(018).
    perform fill_cell using 1 19 1 'Last Date'(019).
    loop at lt_project into ls_project.
    *lt_project_excel[] = lt_project[].
    endloop.
    copy flights to active EXCEL sheet
    h = sy-tabix + 1.
    *perform fill_cell1 using h 1 0 ls_project-PROJECTID.
    *perform fill_cell1 using h 2 0 ls_project-EMPID.
    *perform fill_cell1 using h 3 0 ls_project-PROJECT_NAME.
    *perform fill_cell1 using h 4 0 ls_project-client.
    *perform fill_cell1 using h 5 0 ls_project-BEGIN_DATE.
    *perform fill_cell1 using h 6 0 ls_project-END_DATE.
    *perform fill_cell1 using h 7 0 ls_project-ROLE_OF_EMP.
    *perform fill_cell1 using h 8 0 ls_project-COMPETANCY.
    *perform fill_cell1 using h 9 0 ls_project-EMPLOYEE_NAME.
    *perform fill_cell1 using h 10 0 ls_project-PRICE_CATEGORY.
    *perform fill_cell1 using h 11 0 ls_project-RATE_PER_HOUR.
    *perform fill_cell1 using h 12 0 ls_project-FIRST_DAY_PRO.
    *perform fill_cell1 using h 13 0 ls_project-LAST_DAY_PRO.
    *perform fill_cell1 using h 14 0 ls_project-CKEY.
    *perform fill_cell1 using h 15 0 ls_project-MANAGER.
    *perform fill_cell1 using h 16 0 ls_project-EMPLOYEE_TYPE.
    *perform fill_cell1 using h 17 0 ls_project-DESIGNATION.
    *perform fill_cell1 using h 18 0 ls_project-DATE_OF_JOINING.
    *perform fill_cell1 using h 19 0 ls_project-LAST_WORKING_DAT.
    perform fill_cell1 using h 1 0 lt_project_excel-PROJECTID.
    perform fill_cell1 using h 2 0 lt_project_excel-EMPID.
    perform fill_cell1 using h 3 0 lt_project_excel-PROJECT_NAME.
    perform fill_cell1 using h 4 0 lt_project_excel-client.
    perform fill_cell1 using h 5 0 lt_project_excel-BEGIN_DATE.
    perform fill_cell1 using h 6 0 lt_project_excel-END_DATE.
    perform fill_cell1 using h 7 0 lt_project_excel-ROLE_OF_EMP.
    perform fill_cell1 using h 8 0 lt_project_excel-COMPETANCY.
    perform fill_cell1 using h 9 0 lt_project_excel-EMPLOYEE_NAME.
    perform fill_cell1 using h 10 0 lt_project_excel-PRICE_CATEGORY.
    perform fill_cell1 using h 11 0 lt_project_excel-RATE_PER_HOUR.
    perform fill_cell1 using h 12 0 lt_project_excel-FIRST_DAY_PRO.
    perform fill_cell1 using h 13 0 lt_project_excel-LAST_DAY_PRO.
    perform fill_cell1 using h 14 0 lt_project_excel-CKEY.
    perform fill_cell1 using h 15 0 lt_project_excel-MANAGER.
    perform fill_cell1 using h 16 0 lt_project_excel-EMPLOYEE_TYPE.
    perform fill_cell1 using h 17 0 lt_project_excel-DESIGNATION.
    perform fill_cell1 using h 18 0 lt_project_excel-DATE_OF_JOINING.
    perform fill_cell1 using h 19 0 lt_project_excel-LAST_WORKING_DAT.
    *endloop.
    disconnect from Excel
    *CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
       DOCUMENT_DATA                    =
      PUT_IN_OUTBOX                    = ' '
      SENDER_ADDRESS                   = SY-UNAME
      SENDER_ADDRESS_TYPE              = 'B'
      COMMIT_WORK                      = ' '
    IMPORTING
      SENT_TO_ALL                      =
      NEW_OBJECT_ID                    =
      SENDER_ID                        =
    TABLES
       PACKING_LIST                     =
      OBJECT_HEADER                    =
      CONTENTS_BIN                     =
      CONTENTS_TXT                     =
      CONTENTS_HEX                     =
      OBJECT_PARA                      =
      OBJECT_PARB                      =
       RECEIVERS                        =
    EXCEPTIONS
      TOO_MANY_RECEIVERS               = 1
      DOCUMENT_NOT_SENT                = 2
      DOCUMENT_TYPE_NOT_EXIST          = 3
      OPERATION_NO_AUTHORIZATION       = 4
      PARAMETER_ERROR                  = 5
      X_ERROR                          = 6
      ENQUEUE_ERROR                    = 7
      OTHERS                           = 8
    *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.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    free object h_excel.
    perform err_hdl.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    FORM FILL_CELL *
    sets cell at coordinates i,j to value val boldtype bold *
    form fill_cell using i j bold val.
    call method of h_excel 'Cells' = h_zl exporting #1 = i #2 = j.
    perform err_hdl.
    set property of h_zl 'Value' = val .
    perform err_hdl.
    get property of h_zl 'Font' = h_f.
    perform err_hdl.
    set property of h_f 'Bold' = bold .
    perform err_hdl.
    SET PROPERTY OF h_f 'ColorIndex' = 11 .
    perform err_hdl.
    endform.
    *& Form fill_cell1
    text
    -->P_H text
    -->P_1 text
    -->P_0 text
    -->P_IT_SPFLI_CARRID text
    form fill_cell1 using i j bold val.
    call method of h_excel 'Cells' = h_zl exporting #1 = i #2 = j.
    perform err_hdl.
    set property of h_zl 'Value' = val .
    perform err_hdl.
    get property of h_zl 'Font' = h_f.
    perform err_hdl.
    set property of h_f 'Bold' = bold .
    perform err_hdl.
    SET PROPERTY OF h_f 'ColorIndex' = 14 .
    perform err_hdl.
    endform. " fill_cell1
    *& Form ERR_HDL
    outputs OLE error if any *
    --> p1 text
    <-- p2 text
    form err_hdl.
    if sy-subrc <> 0.
    write: / 'Error in OLE-Automation:'(010), sy-subrc.
    stop.
    endif.
    endform. " ERR_HDL
    Entire excel file is displayed ,but the problem is I want to display the excel file in one shot i.e not <b>line by line</b>
    Kindly suggest if there is any keyword or FM to display the contents in excel using internal table.
    It should not take much time. Just by executing code , the contents of internal table should be displayed.
    Helpful answers will be rewarded
    Thanks,
    Sachin

    Hi Kavitha,
    maybe it's not sophisticated enough for your requirement, but I found function XXL_FULL_API easy to use. This will give same functionality as 'download' button in ALV-Grid display.
    Regards,
    Christian

  • Problem in the internal table of open dataset statement

    Hi abapers,
    I am using the open dataset command to download my file at application server into an internal table.
    But some colums of the internal table are string since i do not want to truncate any of the long text present in the file.
    The open dataset command does not allow the internal table to have string components.
    Is there any workaround by which i can download all the text components of the file without truncating them .
    Regards,
    Aditya

    try to use field symbols:-
    FORM download_file  .
      DATA: l_file TYPE  rlgrap-filename,
            l_line TYPE string.
      DATA: v_excel_string(1000) TYPE c,
              v_len TYPE i,
              v_zover TYPE i .
      FIELD-SYMBOLS: <f>     TYPE ANY .
      CLEAR wa_fin.
    *--- Seting File path
      CONCATENATE p_cfile v_file sy-datum INTO l_file.
    *--- Open data set
      OPEN DATASET l_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc = 0.
        LOOP AT it_down INTO wa_down.
          CLEAR : v_excel_string, v_zover, v_len.
          DO.
            ASSIGN COMPONENT sy-index OF STRUCTURE wa_down TO <f>.
            IF sy-subrc <> 0.
              EXIT. "exits do loop and process next record in itab
            ENDIF.
            DESCRIBE FIELD <f> LENGTH v_len IN CHARACTER MODE.
            v_excel_string+v_zover(v_len) = <f> .
            v_zover = v_zover + v_len .
          ENDDO.
          TRANSFER v_excel_string TO l_file.
          CLEAR : v_excel_string,
                  wa_down       ,
                  v_zover       .
        ENDLOOP.
    *--- Close data set
        CLOSE DATASET l_file.
        IF sy-subrc = 0.
    *--- Success Message
         MESSAGE s000(000) WITH text-018.
        ENDIF.
      ELSE.
    *--- Error unable to open file.
        MESSAGE e000(000) WITH text-017.
      ENDIF.
    ENDFORM.                    " DOWNLOAD_FILE
    Thanks ,
    Ruchi Tiwari

  • Problem in declaring internal table

    hai experts ,
    i am new to web dynpro abap .. my problem is i want to declare a internal table for a table using the web dynpro code wizard .. i found many threads regarding that .. but for mee its not working .. many of them posted that get_static_attributes_table method will solve the problem .. but i used the method in the wizard but it saying that method does not  exist ..pls solve the problem ..
    say where to enter the method in the wizard ..
    thanks & kind regards
    chinnaiya

    Hi Chinnaiya,
    Your post isnt that clear as to what you intend to do. Do you intend to just create an internal table declaration which would be able to hold your context nodes data or do you wish to use the get_static_attributes method to fetch all your tables data into this internal table?
    If you want to just declare an internal table which can hold the data then you would have to do it manually. You can't generate your internal table declaration using the code wizard. Suppose your context nodes name is SFLIGHT then you can use the below syntax to declare a table & work area respectively.
    DATA: lt_sflight TYPE wd_this->elements_sflight,  " Internal table
                wa_sflight TYPE wd_this->element_sflight.  " Work area
    For each node <node> of a controller context, a structure type element_<node> is implicitly generated in the interface IF_<ctrl>. The structure fields correspond to the attributes a node element consists of. Similarly for each node <node> of a controller context, a standard table type elements_<node> is implicitly generated in the interface IF_<ctrl>. The line type of this table is element_<node>. This constant can be used to
    type an internal table that can hold the attributes of multiple node elements. So as how said here you can even declare the work area and internal table like shown below in your MAIN view:
    DATA: lt_sflight TYPE if_main=>elements_sflight,  " internal table
               wa_sflight TYPE if_main=>element_sflight.  " work area
    But the disadvantage of this approach as how pointed out by Thomas in 1 of this earlier threads is that this coding works fine only for this particular view. If you copy the same code and try to use it in another view say VIEW1 then it wouldn't work as the interface name would have changed from if_main to if_view1. So its suggested to use the earlier approach.
    Regards,
    Uday

  • Problem in convering internal table to CSV file

    Hi,
    Iam converting internal table data to CSV format with the code given below.
    LOOP AT it_details_final INTO wa_details_final.
    CLEAR : t_attachment.
    CONSTANTS : c_sep TYPE c VALUE ','.
    CONCATENATE wa_details_final-wf_rectype
                             wa_details_final-wf_bankn
                             wa_details_final-wf_znme1
                             wa_details_final-wf_rzawe
                             wa_details_final-wf_lifnr
                             wa_details_final-wf_chect
                             wa_details_final-wf_rwbtr
                             wa_details_final-wf_chkladat
                        cl_abap_char_utilities=>newline
               INTO t_attachment SEPARATED BY c_sep.
    APPEND t_attachment.
        CLEAR t_attachment.
      ENDLOOP.
    Problem is ,data in one of the fields contain comma ( , ).
    So, data after comma is getting shifted to the adjacent cell.
    Please help me
    Thanks & Regards,
    Sravanthi

    Hello,
    Try this perform
    the ignorefields variable is used if you dont want a particular field in the output. You can ignore it for now
      DATA: p_ignoredfields(1024).
    CONSTANTS : const_sep TYPE c VALUE ','.
    * itab to store data ready to be sent to csv file
      DATA: BEGIN OF wa_csvdata,
        line(4096),
      END OF wa_csvdata.
      DATA: gt_csvdata LIKE TABLE OF wa_csvdata.
    *&      Form  CONVERT_TO_CSV
    *       text
    FORM convert_to_csv  TABLES   lt_datatab USING value(p_ignoredfields).
      FIELD-SYMBOLS: <wa_datatab> TYPE ANY.
      FIELD-SYMBOLS: <wa_field> TYPE ANY.
    * character variable incase table fields are of a diff type (ie: int)
      DATA: lv_data TYPE string.
    * set to X if the no data has been put into the csv workarea
      DATA: flag_firstcol TYPE xflag.
    * move the structure one character to the right since first char
    *  is position 0 in SAP
      SHIFT p_ignoredfields BY 1 PLACES RIGHT.
      REFRESH gt_csvdata.
      CLEAR wa_csvdata.
      LOOP AT lt_datatab ASSIGNING <wa_datatab>.
        flag_firstcol = 'X'.
        DO.
    *  one by one assign each position of the structure to the field
          ASSIGN COMPONENT sy-index OF STRUCTURE <wa_datatab> TO <wa_field>.
          IF sy-subrc <> 0.
            EXIT.
          ELSE.
    *  if the current field needs to be ignored then continue the do loop
            IF p_ignoredfields+sy-index(1) = '.'.
              CONTINUE.
            ENDIF.
    *  we use lv_data since concatenate fails for integer types
            lv_data = <wa_field>.
    *  remove commas in the data
            WHILE sy-subrc = 0.
              REPLACE const_sep WITH '' INTO lv_data.
            ENDWHILE.
    *       if this data belongs to the first non ignored column
            IF flag_firstcol = 'X'.
              wa_csvdata = lv_data.
              flag_firstcol = ''.
            ELSE.
              CONCATENATE wa_csvdata const_sep lv_data INTO wa_csvdata.
            ENDIF.
          ENDIF.
        ENDDO.
        APPEND wa_csvdata TO gt_csvdata.
        CLEAR wa_csvdata.
      ENDLOOP.
    ENDFORM.                    " CONVERT_TO_CSV

  • How to process internal table

    Hi friends/experts,
    My case is:
    1. A dialog screen 100 to display/ update some fields of an internal table itab, Records are processed one by one on the screen
    2. Need UPDATE, DELETE, PREV. NEXT buttons to process records.
    I have made the screen with fields and buttons. What I like to know is how to code DELETE, PREV. and NEXT buttons. Could you kindly provide a sample to do that?
    Thanks.
    Yu

    Hi,
      check this sample code..
    ***Create a global variable for storing the current index that is getting displayed..
    ***I am assuming V_CURRENT_INDEX TYPE SYINDEX.
    CASE SY-UCOMM.
      WHEN 'NEXT'.
    INcrement the index.
        V_CURRENT_INDEX = V_CURRENT_INDEX + 1.
        DESCRIBE TABLE ITAB.
        IF V_CURRENT_INDEX  > SY-TFILL.
    If the current index is greater than the number of rows.
    set the sy-tfill.
          V_CURRENT_INDEX = SY-TFILL.
          MESSAGE S208(00) WITH 'Last record reached'.
          LEAVE SCREEN.
        ENDIF.
    Read the internal table with the current index.
          READ TABLE ITAB INDEX V_CURRENT_INDEX.
    Move the values to the screen variables from the header line of ITAB.
      WHEN 'PREV'.
    Decrement the counter.
        V_CURRENT_INDEX = V_CURRENT_INDEX - 1.
        IF V_CURRENT_INDEX  <  0.
    If the current index is Lesser than zero set 1.
          V_CURRENT_INDEX = 1.
          MESSAGE S208(00) WITH 'First record reached'.
          LEAVE SCREEN.
        ENDIF.
    Read the internal table with the current index.
          READ TABLE ITAB INDEX V_CURRENT_INDEX.
    Move the values to the screen variables from the header line of ITAB.
    ENDCASE.
    Thanks,
    Naren

  • Problem in Importing Internal Table

    Dear All,
    I am exporting Internal table from Program1 as follows:
    REPORT  ZEXPORT_TEST                            .
    TYPES: BEGIN OF ITAB,
          MATNR TYPE MARA-MATNR,
          MATKL TYPE MARA-MATKL,
          END OF ITAB.
    DATA:IT TYPE TABLE OF ITAB .
    SELECT MATNR MATKL FROM MARA INTO TABLE IT UP TO 10 ROWS.
    EXPORT IT TO MEMORY ID 'EAI1'.
    WRITE:/'Exported Successfully'.
    And I am Importing same internal table into  program2
    REPORT  ZIMPORT_TEST  .
    TYPES: BEGIN OF ITAB,
          MATNR TYPE MARA-MATNR,
          MATKL TYPE MARA-MATKL,
          END OF ITAB.
    DATA:IT  TYPE TABLE OF ITAB,
         IT1 TYPE TABLE OF ITAB,
         WA TYPE ITAB.
    IMPORT IT1 FROM MEMORY ID 'EAI1'.
    IT[] = IT1[].
    LOOP AT IT INTO WA.
      WRITE:/ wa-matnr,
            / WA-MATKL.
    ENDLOOP.
    WRITE:/'Imported Successfully'.
    But progam1 exporting correctly the return code is 0 but program2 is not importing sucessfully return code is 4.
    Kindly help me to import.
    Thanks in Advance.

    Hi friend,
    When u use 'Export' and 'Import' statements, it refers local sap memory.
    So u need to use SUBMIT ZIMPORT_TEST AND RETURN  statement immediately after 'Export'.
    i.e.
    Report ZEXPORT_TEST.
    EXPORT IT TO MEMORY ID 'EAI1'.   < -
    Exported to common local sap memory
    SUBMIT ZIMPORT_TEST AND RETURN . <---- Controls goes to next program, within same session.
    Report ZIMPORT_TEST.
    IMPORT IT from MEMORY ID 'EAI1'.  <----
    Imports data from common local sap memory.
    If u want to run two independent reports one exporting, another importing, then u have to use
    'SET' and 'GET' parameter concept which refers global sap memory.
    Thanks..
    Edited by: Sap Fan on Feb 27, 2009 4:56 AM
    Edited by: Sap Fan on Feb 27, 2009 4:56 AM

  • Problem creating an internal table dynamically

    Hi,
    I'm trying to create an internal table dynamically as i would be able to determine the structure of the table based on the user input.
    I've used the sample code from this forum ...
    REPORT  ZRICH_0003       .
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: alv_fldcat type slis_t_fieldcat_alv,
                   it_fldcat type lvc_t_fcat.
                   type-pools : abap.
    data : it_details type abap_compdescr_tab,
           wa_details type abap_compdescr.
    data : ref_descr type ref to cl_abap_structdescr.
    data: new_table type ref to data,
          new_line  type ref to data,
          wa_it_fldcat type lvc_s_fcat.
          selection-screen begin of block b1 with frame title text.
    parameters: p_table(30) type c.
    selection-screen end of block b1.
    Get the structure of the table.
    ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
    it_details[] = ref_descr->components[].
    loop at it_details into wa_details.
      clear wa_it_fldcat.
      wa_it_fldcat-fieldname = wa_details-name .
      wa_it_fldcat-datatype = wa_details-type_kind.
      wa_it_fldcat-inttype = wa_details-type_kind.
      wa_it_fldcat-intlen = wa_details-length.
      wa_it_fldcat-decimals = wa_details-decimals.
      append wa_it_fldcat to it_fldcat .
      endloop.
    Create dynamic internal table and assign to FS
    call method cl_alv_table_create=>create_dynamic_table
                exporting
                it_fieldcatalog = it_fldcat
                importing
                ep_table        = new_table.
    assign new_table->* to <dyn_table>.
    Create dynamic work area and assign to FS
    create data new_line like line of <dyn_table>.
    assign new_line->* to <dyn_wa>.
    <b>* Select Data from table.
    select * into table <dyn_table>           from
    (p_table).</b>
    Write out data from table.
    loop at <dyn_table> into <dyn_wa>.
    do.
    assign component  sy-index  of structure <dyn_wa> to <dyn_field>.
    if sy-subrc <> 0.
    exit.
    endif.
    if sy-index = 1.
    write:/ <dyn_field>.
    else.
    write: <dyn_field>.
    endif.
    enddo.
    endloop.
    I'm able to get the structure of the table that i want, but when i'm trying to select data from the table into this internal table..as highlighted in the sample code above..i'm getting a short dump...saying that ' the database table is 600 bytes wide but the internal table is only 576 bytes wide.
    The internal table is declared as
    field-symbols: <dyn_table> type standard table..
    Could anyone please tell me how to rectify this.
    Thanks in advance,
    Harsha.

    Hi Smitha,
    I'm building the internal table by getting the structure using the method
    cl_abap_typedescr=>describe_by_name( p_table ).
    where p_table is the table name determined dynamically..
    Now using this structure, i'm building an internal table by calling the method
    call method cl_alv_table_create=>create_dynamic_table
    I've checked all the fields after the internal table has been created .. and it contains all the fields of the table that i'm supplying initially..
    But when i read data into that internal table, it gives me that dump..I've described it in this post earlier.
    Any more suggestions would be very helpful.
    Thanks,
    Harsha

  • Problem in printing internal table data in Sapscript!

    Hi All,
    Am trying to print internal table data into main window of sapscript.
    This is what I have written.
    loop at it_final INTO wa_final.
                  CALL FUNCTION 'WRITE_FORM'
                   EXPORTING
                     window   = 'MAIN'
                     ELEMENT  = '670'
                     TYPE     = 'BODY'
                     FUNCTION = 'APPEND'
                   EXCEPTIONS
                     window  = 1
                     element = 2.
                 IF sy-subrc <> 0.
                 ENDIF.
    ENDLOOP.
    IN Sapscript :
    /E   670
    IT     &wa_final-vbeln&,,&wa_final-vbelv&,,&wa_final-payment&
    =      &wa_final-rundate&,,&wa_final-waers&,,&wa_final-creditcard&
    =      &wa_final-augru&,,&wa_final-dmbtr&
    Pls let me know if am missing anything.
    Thanks & Regards
    Himayat

    Check if your Programm is called at the Sapscript level.
    Are you calling the programm from the Sapscript using the PERFORM command? or are these Programm and Sapscript set in customizing?
    Using SE16 check the Message Type and see if Sapscript and the programm are connected at all.

  • Problem in exporting internal table to memory

    Hi,
    I have to export two internal tables (thead and titem) from a report (RFTBCF00) to memory which i will import in my function module can anyone letme know hw it cud b done .
    Points will b assigned
    Thnx,

    You can take the help of this example:
    report  z_82235_test1                           .
    types: begin of tab1,
             a(1),
             b(1),
           end of tab1.
    types: begin of tab2,
             c(1),
             d(1),
           end of tab2.
    data: itab1 type table of tab1,
          wa1 like line of itab1,
          itab2 type table of tab2,
          wa2 like line of itab2.
    wa1-a = '1'.
    wa1-b = '2'.
    append wa1 to itab1.
    clear wa1.
    wa1-a = '3'.
    wa1-b = '4'.
    append wa1 to itab1.
    clear wa1.
    export itab1 to memory id '001'.
    export itab2 to memory id '002'.
    submit z_82235_test2 and return exporting list to memory .

Maybe you are looking for