How to add the contents of a field of internal table.

Hello Everybody,
How to sum up the individual field from a internal table. Like i have a internal table that has menge field , I need to sum up the menge field for each matnr..
exm : for each matnr there are 5 menge entries, I need to add all the menge fields and shud be put against the matnr .
Thanks,

Hi Khaleel,
One more option is using the "collect" statement.....
imagine in the internal table itab..we have 2 fields only..
MATNR,MENGE,
we have 2 internal tables itab1 and itab2...
loop at itab1.
collect itab1 to itab2.
endloop.
Action performed is ...for the same MATNR...menge gets added and saved as a single record...When matnr changes...new record is Appended
another case is we have 3 fields in internal table
MATNR,UNIT,MENGE
imagine we hane the records
Material1 KG  100
Material1 LT   20
Material1 LT   200
MAterial2 KG 100
in this case...the output will be
Material1 KG 100
Material1 LT  220
MAterial2 KG 100
Reason is that the fields before the addable value is checked for similarity..
here field UNIT is also checked and also MATNR before adding up....
Hope it gave you some alternative idea to proceed with....
Reward if helpful
Regards
Byju

Similar Messages

  • How to find the number of columns in an internal table DYNAMICALLY ?

    Hi,
    How to find the number of columns in an internal table DYNAMICALLY ?
    Thanks and Regards,
    saleem.

    Hi,
    you can find the number of columns and their order using
    the <b>'REUSE_ALV_FIELDCATALOG_MERGE'</b>
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = sy-repid
       I_INTERNAL_TABNAME           = 'ITAB'
       I_INCLNAME                   = sy-repid
      changing
        ct_fieldcat                  = IT_FIELDCAT
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif
    now describe your fieldcat . and find no of columns.
    and their order also..
    regards
    vijay

  • How to Display the content of Excel file into Webdynpro Table

    Hi Experts
    I am following the Blog to upload a file in to the webdynpro context,but my problem is after uploading a excel file i need to extract the content from that Excel file and that content should be displayed in the webdynpro table.Can any body please guide me how to read the content from excel and to Display in the Table.
    Thanks and Regards
    Kalyan

    HI,
    Take for example, if Excel file contains 4 fields,
    Add jxl.jar to JavaBuild path and Use this snippet
    File f=new File("sample.xls");
    Workbook w=Workbook.getWorkbook(f);
    Sheet sh=w.getSheet(0);
    int cols=sh.getColumns();
    int rows=sh.getRows();
    Cell c=null;
    String s1=null;
    String s2=null;
    String s3=null;
    String s4=null;
    ArrayList al=new ArrayList();
    int j=0;
    for(int i=1;i<rows;i++)
    ITableElement table=wdContext.createTableElementz
         s1=sh.getCell(0,i).getContents();
         s2=sh.getCell(1,i).getContents();
         s3=sh.getCell(2,i).getContents();
         s4=sh.getCell(3,i).getContents();
                             table.setName(s1);
         table.setAddress(s2);
         table.setDesignation(s3);
         table.setDummy(s4);
         al.add(j,table);
         j++;                    
    wdContext.nodeTable().bind(al);
    Regards
    LakshmiNarayana

  • Read contents of changing fields from internal table

    Hi Folks,
    Please help me in my query below:
    Consider there is a Z-table with two fields TABNAM and FIELD having values KNA1 and NAME1 respectively.
    In my report I have fetched entries for customers from KNA1. Now based on the field from Z-table I want to populate a variable suppose V_FREE_VAR with the value from KNA1 table.
    Here V_FREE_VAR is of CHAR200 so that it accomodate all types of values from KNA1.
    The value of Z-table FIELD can change daily i.e next day the value may be PSTLZ.
    So how can I read the particular field from internal table as the field to be read is dynamic.
    Note: using case is not feasible.
    Thanks in advance.
    Regards,
    Shardul

    @Hartmut P
    As Rob said i want to get the value of the field from internal table. the code is something like this.
    I_KNA1 contains records for customers.
    Suppose values of Z-table are in internal table I_TEMP_TABLE.
    Entries in I_TEMP_TABLE are as follows
    TABNAME      FIELDNAME
    KNA1                 NAME1
    The value of FIELNAME in Z-table can be changed
    Loop at I_TEMP_TABLE into WA_TEMP_TABLE.
    Read I_KNA1 into WA_KNA1 with key KUNNR = '0001002234'.
    IF SY-SUBRC EQ 0.
       CASE WA_TEMP_TABLE-FIELDNAME.
            WHEN 'NAME1'.
                 V_VAR = WA_KNA1-NAME1.
             WHEN 'PSTLZ'
                  V_VAR = WA_KNA1-PSTLZ.
    ENDIF.
    But using case is not appropriate as KNA1 contains 176 fields.

  • How to read the contents of Input Field created via Screen Painter?

    Hi All,
    I have a module program / dialog program, on my second screen, I created an input/outbox field via screen painter of course,
    now in my PAI, how can I read the contents of the input/outbox field?
    Let's say the name of my input/outbox field is: P_WEKRS.  Note: Get Parameter and Set Parameter is ticked.
    PROCESS AFTER INPUT.
      LOOP WITH CONTROL TC_DATA.
        MODULE MODIFY_DATA.
      ENDLOOP.
    I want to get the value of the input/outbox field before my loop in table control?  I thought that it will work like normal parameter in non-dialog programs.
    Any helpful inputs will be appreciated/rewarded.
    Thanks.
    Jaime

    Hi, Jaime
    Do the following Change in you Follow Logic
    PROCESS AFTER INPUT.
    MODULE read_or_change_value. " Add this
    LOOP WITH CONTROL TC_DATA.
      MODULE MODIFY_DATA.
    ENDLOOP.
    Add the Bellow Module code in you Driver Program.
    MODULE read_or_change_value.
    DATA: P_WEKRS like " the Field on Screen. Must be the same name as on SCREEN. and Type must be same too.
    " Here you will find the Value in that Variable or if you will change the Value here you will find it change on Screen
    END MODULE.
    Please Reply if any Issue..
    Best Regards,
    Faisal

  • How to Convert the content in BLOB field into a PDF file...

    Hi,
    I am having PDF files stored in BLOB column of a table in Oracle Database (11G R2).
    I want to retrieve the files back and store them in hard disk. I am successful in storing the content as a file with '.doc' but if I store the file as '.pdf', adobe fails to open the file with error
    Adobe Reader could not open file 'xxx.pdf' because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded)
    I am using following example code to achieve my goal...
    Declare
    b blob;
    c clob;
    buffer VARCHAR2(32767);
    buffer_size CONSTANT BINARY_INTEGER := 32767;
    amount BINARY_INTEGER;
    offset NUMBER(38);
    file_handle UTL_FILE.FILE_TYPE;
    begin
    select blob_data into b from blobdata where id=1;
    c := blob2clob(b);
    file_handle := UTL_FILE.FOPEN('BLOB2FILE','my_file.pdf','w',buffer_size);
         amount := buffer_size;
         offset := 1;
         WHILE amount >= buffer_size
         LOOP
              DBMS_LOB.READ(c,amount,offset,buffer);
              -- buffer:=replace(buffer,chr(13),'');
              offset := offset + amount;
              UTL_FILE.PUT(file_handle,buffer);
              UTL_FILE.FFLUSH(file_handle);
         END LOOP;
         UTL_FILE.FCLOSE(file_handle);
    end;
    create or replace FUNCTION BLOB2CLOB ( p_blob IN BLOB ) RETURN CLOB
    -- typecasts BLOB to CLOB (binary conversion)
    IS
    || Purpose : To Convert a BLOB File to CLOB File
    || INPUT : BLOB File
    || OUTPUT : CLOB File
    || History: MB V5.0 24.09.2007 RCMS00318572 Initial version
    ln_file_check NUMBER;
    ln_file_size NUMBER;
    v_text_file CLOB;
    v_binary_file BLOB;
    v_dest_offset INTEGER := 1;
    v_src_offset INTEGER := 1;
    v_warning INTEGER;
    lv_data CLOB;
    ln_length NUMBER;
    csid VARCHAR2(100) := DBMS_LOB.DEFAULT_CSID;
    V_LANG_CONTEXT NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
    BEGIN
    DBMS_LOB.createtemporary (v_text_file, TRUE);
    SELECT dbms_lob.getlength(p_blob) INTO ln_file_size FROM DUAL;
    DBMS_LOB.converttoclob (v_text_file, p_blob, ln_file_size, v_dest_offset, v_src_offset, 0, v_lang_context, v_warning);
    SELECT dbms_lob.getlength(v_text_file) INTO ln_length FROM DUAL;
    RETURN v_text_file;
    END;

    user755667 wrote:
    Hi,
    I am having PDF files stored in BLOB column of a table in Oracle Database (11G R2).
    I want to retrieve the files back and store them in hard disk. I am successful in storing the content as a file with '.doc' but if I store the file as '.pdf', adobe fails to open the file with error
    Adobe Reader could not open file 'xxx.pdf' because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded)
    I am using following example code to achieve my goal...
    Declare
    b blob;
    c clob;
    buffer VARCHAR2(32767);
    buffer_size CONSTANT BINARY_INTEGER := 32767;
    amount BINARY_INTEGER;
    offset NUMBER(38);
    file_handle UTL_FILE.FILE_TYPE;
    begin
    select blob_data into b from blobdata where id=1;
    c := blob2clob(b);
    file_handle := UTL_FILE.FOPEN('BLOB2FILE','my_file.pdf','w',buffer_size);
         amount := buffer_size;
         offset := 1;
         WHILE amount >= buffer_size
         LOOP
              DBMS_LOB.READ(c,amount,offset,buffer);
              -- buffer:=replace(buffer,chr(13),'');
              offset := offset + amount;
              UTL_FILE.PUT(file_handle,buffer);
              UTL_FILE.FFLUSH(file_handle);
         END LOOP;
         UTL_FILE.FCLOSE(file_handle);
    end;
    create or replace FUNCTION BLOB2CLOB ( p_blob IN BLOB ) RETURN CLOB
    -- typecasts BLOB to CLOB (binary conversion)
    IS
    || Purpose : To Convert a BLOB File to CLOB File
    || INPUT : BLOB File
    || OUTPUT : CLOB File
    || History: MB V5.0 24.09.2007 RCMS00318572 Initial version
    ln_file_check NUMBER;
    ln_file_size NUMBER;
    v_text_file CLOB;
    v_binary_file BLOB;
    v_dest_offset INTEGER := 1;
    v_src_offset INTEGER := 1;
    v_warning INTEGER;
    lv_data CLOB;
    ln_length NUMBER;
    csid VARCHAR2(100) := DBMS_LOB.DEFAULT_CSID;
    V_LANG_CONTEXT NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
    BEGIN
    DBMS_LOB.createtemporary (v_text_file, TRUE);
    SELECT dbms_lob.getlength(p_blob) INTO ln_file_size FROM DUAL;
    DBMS_LOB.converttoclob (v_text_file, p_blob, ln_file_size, v_dest_offset, v_src_offset, 0, v_lang_context, v_warning);
    SELECT dbms_lob.getlength(v_text_file) INTO ln_length FROM DUAL;
    RETURN v_text_file;
    END;I skimmed this and stopped reading when i saw the BLOB to CLOB function.
    You can't convert binary data into character based data.
    So very likely this is your problem.

  • How to see the dropdown option for field of a table during selection

    Hello,
    I am adding a new custom field in the table. Now when user goes to the screen after clicking the content button icon in se11, he sees all fields for selection.
    That custom field is one character field. I want the user to see P and S option when he hits F4 (Dropdown).
    How can I achieve this ?
    Regards,
    Rajesh.

    hi check this..
    report .
    TYPE-POOLS : vrm.
    TABLES:vbak,vbap.
    DATA : v(80) TYPE c.
    DATA: wa_vbak TYPE vbak,
          it_vbak TYPE vbak OCCURS 0 WITH HEADER LINE,
          wa_vbap TYPE vbap,
          it_vbap TYPE vbap OCCURS 0 WITH HEADER LINE.
      DATA: l_name TYPE vrm_id,
            li_list TYPE vrm_values ,
            v_count  TYPE i,
            l_value LIKE LINE OF li_list.
    PARAMETERS: p_test(20) AS LISTBOX VISIBLE LENGTH 60 MODIF ID DAT.
    INITIALIZATION.
    AT SELECTION-SCREEN OUTPUT.
      PERFORM get_data.
      LOOP AT it_vbak.
        l_value-key =  it_vbak-vbeln .
        l_value-text = it_vbak-vbeln .
        APPEND l_value TO li_list.
      ENDLOOP.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id              = 'P_TEST'
          values          = li_list
        EXCEPTIONS
          id_illegal_name = 1
          OTHERS          = 2.
    AT SELECTION-SCREEN ON P_TEST.
      clear : li_list , li_list[].
      SELECT vbeln
             matnr
             meins
             FROM vbap
             INTO CORRESPONDING FIELDS OF TABLE it_vbap
             WHERE vbeln = p_test.
    START-OF-SELECTION.
      SELECT vbeln
             matnr
             meins
             FROM vbap
             INTO CORRESPONDING FIELDS OF TABLE it_vbap
             WHERE vbeln = p_test.
      LOOP AT it_vbap.
        WRITE :/ it_vbap-vbeln, it_vbap-matnr,it_vbap-meins.
      ENDLOOP.
    *&      Form  get_Data
          text
    -->  p1        text
    <--  p2        text
    FORM get_data .
      SELECT  vbeln
              FROM vbak
              INTO  CORRESPONDING FIELDS OF TABLE it_vbak.
    ENDFORM.                    " get_Data
    regards,
    venkat

  • How to store the content of a file in oracle table.

    Hello,
    I have a .xml file in unix , how can i upload the content of that file into a column of a table in oracle?

    Did you look at the link posted in response to the OP? At a quick look, it seems fairly reasonable to me.
    John

  • How to transfer the contents of a line of a table control to second screen?

    Hi,
    I have a table control and I have entered some contents in one line of a table control .
    When i click on this line and then click on the detail button on the screen , it should take me to another screen and whatever I have entered in the table control should be transferred to the second screen .
    Please could anyone help me out with this .
    Regards,
    Sushanth H.S.

    Hi
    U need to get the index of the line of table control by command GET CURSOR:
    PROCESS PAI.
    LOOP AT ITAB.
       MODULE GET_CURSOR.
       MODULE MODIFY_ITAB.
    ENDLOOP.
    MODULE USER_COMMAND.
    Module to pick up the selected line:
    MODULE GET_CURSOR.
      GET CURSOR LINE VN_LINE.
    ENDMODULE.
    Module to transfer the data from table control to internal table:
    MODULE MODIFY_ITAB.
      ITAB-FIELD1 = <FIELD OF TABLE CONTROL>.
      MODIFY ITAB INDEX <TABLE CONTROL>-CURRENT_LINE.
    ENDMODULE.
    U should considere the variable line has the value of the index of the line of table control, so u need to calculate the number of the corresponding line of internal table:
    MODULE USER_COMMAND.
      CASE OK_CODE.
        WHEN 'DETAIL'.
    * Calculate the line of internal table:
           VN_LINE = <TABLE CONTROL>-TOP_LINE + VN_LINE - 1.
    * Read the data
           READ TABLE ITAB INDEX VN_LINE.
    * Transfer the data to the output structure of the new screen
           <STRUCTURE>-FIELD1 = ITAB-FIELD1.
    * Call the new screen
           SET SCREEN <NEW SCREEN>.
           LEAVE SCREEN.
    Max

  • How to delete duplicates of some specific fields in internal table

    i am having internal table of it_ekko.
    in that i am having some data of PO no, Line Item,IR value and IR qty......
    i am having data like below.
    PO                        Line Item   IR Value    IR QTY 
    200310051          0010         1500           4500
    200310051          0010        1500           4500
    200310052         0010           0                   0
    200310052          0010       0               0
    now where ever IR value and IR qty is present i wanted that to display only once against that PO and line item
    i wanted like below
    PO                        Line Item   IR Value    IR QTY 
    200310051          0010         1500           4500
    200310051          0010            0              0
    200310052         0010             0                0
    200310052          0010            0               0
    Field names for IR value and IR Qty are Menge2 and dmbtr2.
    How to do that.........
    I cant use
    Delete adjacent duplicates of it_ekko by ebeln = wa_ekko-ebeln and
                                                                          ebelp = wa_ekko-ebelp.
    because i wanted that po and same line items , how many times it is like that only.....
    in it_ekko table i only wanted to delete duplicates of menge2 and dmbtr2.
    Pls suggest the code

    sort itab by po item ascending.
    loop at itab into wa.
    at new wa-item.
    if wa-qty1 ne 0 and wa-qty2 ne 0.
    move wa to wa_final.
    append wa_final to i_final.
    endat.
    endloop.
    or
    loop at itab into wa.
    at new wa-item.
    if wa-qty1 ne 0 and wa-qty2 ne 0.
    write wa.
    endat.
    endloop.
    make sure that the qty1 and qty2 is not character type , then in control statement it will replaced by *.

  • How to get the NameTab Structure(X031L) for Dynamic internal table?

    when we pass standard table to the FM 'DD_GET_NAMETAB' we will get the
    nametab structure(x031l), like this i want to get the same structure for
    dynamic internal  table . how can I achieve this
    please help me...

    Hi,
    try this method
    REPORT zmaschl_create_data_dynamic .
    TYPE-POOLS: slis.
    DATA: it_fcat TYPE slis_t_fieldcat_alv,
          is_fcat LIKE LINE OF it_fcat.
    DATA: it_fieldcat TYPE lvc_t_fcat,
          is_fieldcat LIKE LINE OF it_fieldcat.
    DATA: new_table TYPE REF TO data.
    DATA: new_line  TYPE REF TO data.
    FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
                   <l_line>  TYPE ANY,
                   <l_field> TYPE ANY.
    Build fieldcat
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'       EXPORTING           i_structure_name = 'SYST'       CHANGING           ct_fieldcat      = it_fcat[].   LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.        MOVE-CORRESPONDING is_fcat TO is_fieldcat.        is_fieldcat-fieldname = is_fcat-fieldname.        is_fieldcat-ref_field = is_fcat-fieldname.        is_fieldcat-ref_table = is_fcat-ref_tabname.        APPEND is_fieldcat TO it_fieldcat.   ENDLOOP.
    Create a new Table
    CALL METHOD cl_alv_table_create=>create_dynamic_table       EXPORTING        it_fieldcatalog = it_fieldcat       IMPORTING        ep_table        = new_table.
    Create a new Line with the same structure of the table.
    ASSIGN new_table->* TO <l_table>.CREATE DATA new_line LIKE LINE OF <l_table>.ASSIGN new_line->* TO <l_line>.
    Test it...
       DO 30 TIMES.
          ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
          <l_field> = sy-index.
          INSERT <l_line> INTO TABLE <l_table>.
       ENDDO.
       LOOP AT <l_table> ASSIGNING <l_line>.
          ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
          WRITE <l_field>.
       ENDLOOP.

  • How to add deep structure like LVC_T_SCOL in dynamic internal table

    Hello,
    can any one help me with adding a deep structure to a dynamically created internal table. the deep structure which needs to be added is for the color purpose for each record i.e.  LVC_T_SCOL .
    Dynamic table created with below method.
        CALL METHOD cl_alv_table_create=>create_dynamic_table
          EXPORTING
            it_fieldcatalog  = gt_struct
            i_length_in_byte = 'X'
          IMPORTING
            ep_table         = dy_table.
        ASSIGN: dy_table->* TO <dyn_table>,
                dy_table->* TO <dyn_line>.
    gt_struct has the list of fields and their technical attributs.
    Thanks In Advance.
    BR,
    Rajesh

    can you add a column name and attribs in gt_struct?  It needs to be declared like:
    <colorcolumnname>    type lvc_t_scol.

  • How to get the Database Type quan in my internal table?

    Hi, I have the following problem, I have a Database Table with a column foo (QUAN with length 15 and 3 dec). Now I want to read this field into a Internal Table and the corrospoding field is:
    foo(19) TYPE C,
    But this is not working I'm getting the dump:
    DBIF_RSQL_INVALID_RSQL
    CX_SY_OPEN_SQL_DB
    What is the correct abap type in my structure to put this QUAN in my internal table?

    Hi Michael,
         when you know your data base field name then u can define your variable f00 of your db field type like
         foo type <dbtabname>-<fieldname)  -----ex -- j_1iexcdtl-menge
         or define foo as packed no
         data : foo(19) type p decimals 3.
    Regards

  • How to add search help to a field in MARA table

    Hi,
    According to my requirement,I need to add search help to one of the field in MARA.It is checkbox now and it has to be changed to drop down.
    How to do this please help.

    hi u can use HELP-REQUEST option at selection screen or VALUE-REQUEST
    The addition on Value-REQUEST displays the pushbuttuon for F4 help for the corresponding field.
    The value selection is controlled by interactive events.
    pradeep

  • How to add the Row count(number of rows in table)  in  the table header?

    Hi,
    I'm having a table. This table is viewed when i click on a search button.
    <b>On the table header it should dynamically display the number of rows in the table, i.e., the row count.</b>
    How to do this? could any one explain me with the detailed procedure to achieve this.
    Thanks & Regards,
    Suresh

    If you want to show a localized text in the table header, you should use the <b>Message Pool</b> to create a (parameterized) message "tableHeaderText" like "There are table entries".
    Next, create a context attribute "tableHeaderText" of type "string" and bind the "text" property of the table header Caption UI element to this attribute.
    Whenever the table data has changed (e.g. at the end of the supply function for the table's data source node), update the header text:
    int numRows = wdContext.node<TableDataSourceNode>().size();
    String text = wdComponentAPI.getTextAccessor().getText
      IMessage<ComponentName>.TABLE_HEADER_TEXT,
      new Object[] { String.valueOf(numRows) }
    wdContext.currentContextElement().setTableHeaderText(text);
    Maybe you want to provide a separate message for the case that there are no entries.
    Alternatively, you can make the attribute calculated and return the header text in the attribute getter.
    Armin

Maybe you are looking for

  • Delta update for 0FI_AR_4 DataSource

    Hi Experts, We have a couple of reports (Infoprovider ODS) which are based on the 0FI_AR_4 DataSource. We have enhanced the Datasource and added 7 to 8 fields from SD and FI region. For enabling delta current mapping is: UPDMOD (R/3) field mapped to

  • How to automatically login to apex and run a specific page / application

    Hi all. I'd like to know if there is a way of automatically login to apex and run a specific page / application. I mean, invoke browser and pass the necessary information to login (not public user) and run a specific application( ina secure way if po

  • Adobe Media Converter problems...

    Problem #1 - seems when I'm trying to convert larger files, I instantly get the message in the timeline "Conforming file..." - this NEVER goes away.  However, 9 times out of 10, if I restart my machine and try again it will instantly start encoding w

  • When I try to redeem an app download code, it tells me to confirm that I am 17  and that it'll download immediately but it doesn't.

    When I try to redeem an app download code, it tells me to confirm that I am 17+  and that it'll download immediately but it doesn't. What I mean is, as soon as I put in the code and click redeem, it comes up with the message saying to confirm that I

  • Incorrect status in pricing in process SC.

    Hi masters. the vesion SRM 7.0 was updated the version SP5 to SP8 of ABAP and other components like java. after that changes the sistems was Ok. but now no working when try make sc since catalog or free text the sistem show a dump Incorrect status in