Loop statement in ABAP OO

Hi,
I am trying to change a BADI interface and since BADIs use ABAP OO, a simple loop statement fails to work.
I need to loop through an internal table and for each record in the internal table I need to read another db table which has a field in common with the internal table.
Ideally,
Loop at lt_selections
select logsys from /bic/mzcs_unit where /bic/zcs_unit = lt_selections-cs_unit
endloop.
But this piece of code fails to work in BADI because of OO concepts.
Can anyone help me out here?
THank you

As Alejandro said, if you are getting a syntax error, it is probably because <b>header lines are not allow in OO</b>.
data: wa_selections like line of lt_selections.
Loop at lt_selections into wa_wa_selections.
select logsys from /bic/mzcs_unit
     where /bic/zcs_unit = wa_selections-cs_unit.
endloop.
Regards,
Rich Heilman
Message was edited by: Rich Heilman

Similar Messages

  • Regarding LOOP Statement in ABAP

    Hi,
    I have small question regarding <b>LOOP ..... ENDLOOP</b> statement against <b>SY-SUBRC</b> Check.
    I have a loop as below:
    <b> LOOP AT i_vbap WHERE vbeln = i_vbak-vbeln.
        Some Code
        ENDLOOP.
        IF sy-subrc <> 0.
          APPEND i_sdata.
          CLEAR i_sdata.
        ENDIF.</b>
    Is the above <b>Code/Syntax</b> is correct one.
    Can we use <b>SY-SUBRC</b> Check against <b>LOOP ...  ENDLOOP</b> statement.
    Is this the right way of writing the code as per standards.
    Can anybody give sujjestions regarding the same.
    Thanks in advance.
    Thanks & Regards,
    Prasad.

    Hi Prasad,
    Yes, you could use sy-subrc after the endloop. For example:
    loop at itab1 where kunnr = itab2-kunnr.
    some conditions...
    endloop.
    if sy-subrc = 0.
    write: 'Success!'.
    else.
    leave program.
    endif.
    if you press F1 while highlighting the LOOP statement here are the meaning of sy-subrc in loop...endloop.
    SY-SUBRC = 0:
    At least one loop pass was processed.
    SY-SUBRC = 4:
    The loop was not processed because the table contains no entries or no entries satisfied the conditions.
    Regards!

  • My loop statement in smartforms seems not to be working...

    Hello Experts,
    I am currently practicing smartforms and I am trying to display the records of my internal table.
    What I did was in my table under MAIN window I have put the statement:
    it_spfli into wa_spfli and also in my main area of my table I have a loop statement. Now, in one of my text
    i put wa_spfli-carrid, wa_spfli-countryfr, etc. But it still does not show any data.Help would be greatly appreciated.

    u will be getting a function module name for the smartform then
    goto se37-->enter the FM name -->search for the ITAB you r using then put a break point.
    come back to u r program the run.. controle will stops over there then check whether the data is populating or not.
    INPUT and OUTPUT patameters are for program line and INITIALIZATION tabs.. when you want to modify some data in these you need to give the veriable or ITABs u r using inside. so that system will determine the global declarations(veriable or ITAbs).
    for more info refer these links
    http://www.sap-img.com/smartforms/sap-smart-forms.htm
    http://www.sap-img.com/smartforms/smartform-tutorial.htm
    http://www.sapgenie.com/abap/smartforms.htm

  • Using a recordset in a loop statement

    Hello all,
    I am (still) trying to get an Excel spreadsheet for a dynamically created table. A crucial parameter of the problem is that I do not know the column names for my table at runtime, as it is created by a pivot query.
    I was very excited to find Tom Kyte's post on "Using a recordset in a loop statement:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:4768329722850645393::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:464820324673,
    This is precisely the solution I need. Unfortunately for me, when I create my stored procedure, it doesn't compile. As suggested I systematically renamed EXEC_SQL to DBMS_SQL, then I made some minor tweaks to integrate with HTMLDB:
    create or replace procedure export_tsv as
    connection_id DBMS_SQL.CONNTYPE
    default DBMS_SQL.default_connection;
    cursorID DBMS_SQL.CURSTYPE;
    nIgn number;
    columnValue varchar2(4000);
    ncols number;
    sep varchar2(1);
    colName varchar2(40);
    colLen number;
    coltype number;
    BEGIN
    IF DBMS_SQL.is_connected = FALSE THEN
    Message('No primary connection. Please connect.');
    RETURN;
    END IF;
    -- set up for excel spreadsheet
    htp.init;
    owa_util.mime_header ('application/vnd.ms-excel',false);
    htmldb_application.g_page_text_generated := true;
    htp.p('Content-Disposition: attachment;
    filename=myexport.txt');
    owa_util.http_header_close;
    -- end excel spreadsheet setup
    cursorID := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(cursorID, 'select * from exp_data', DBMS_SQL.V7);
    nIgn := DBMS_SQL.EXECUTE(cursorID);
    for i in 1 .. 1000 loop
    begin
    DBMS_SQL.describe_column( connection_id, cursorId, i,
    colName, colLen, colType );
    DBMS_SQL.define_column(cursorID, i, columnValue,
    4000 );
    exception
    when DBMS_SQL.invalid_column_number then
    ncols := i-1;
    exit;
    end;
    end loop;
    while (DBMS_SQL.fetch_rows(cursorID) > 0)
    loop
    sep := '';
    for i in 1 .. ncols loop
    DBMS_SQL.COLUMN_VALUE(cursorID, i, columnValue);
    -- print the column value
    htp.p( sep || columnValue);
    sep := chr(9);
    end loop;
    -- print the end of line CRLF
    htp.p(chr(13)|| chr(10));
    END LOOP;
    DBMS_SQL.CLOSE_CURSOR(cursorID);
    DBMS_SQL.CLOSE_CONNECTION;
    END;
    When I try to run this in the HTMLDB SQL Command Processor, I see the following error:
    ERROR at line 2: PLS-00302: component 'CONNTYPE' must be declared
    Can someone provide me with the correct translation of Tom Kyte's approach into the HTMLDB idiom?
    Thanks in advance,
    susan

    Questions about opening multiple worksheets on the web:
    I have this link that submits the page and my process calls a PL/SQL procedure that prints out an excel spreadsheet. When I hit the link again, the spreadsheet does not update. I can make the spreadsheet update from ASP or a java servlet, but never from the PL/SQL procedure. Even if I use the procedure to print out XML in XMLSS format, so that I can change worksheet name, it still does not update on successive calls.
    My code:
    PROCEDURE SQL_TO_EXCEL(p_sql in varchar2)
    as
    l_cursor integer default dbms_sql.open_cursor;
    l_status PLS_INTEGER;
    l_desc dbms_sql.desc_tab;
    l_col_cnt number;
    l_columnValue varchar2(4000);
    l_row varchar2(4000);
    l_frow PLS_INTEGER;
    l_lrow PLS_INTEGER;
    l_cols varchar2(4000);
    l_date date;
    begin
    --set mime type to Excel
    htp.init;
    owa_util.mime_header('application/vnd.ms-excel',true);
    --htp.p('Pragma: no-cache');
    --htp.p('Cache-Control: no-cache');
    --owa_util.http_header_close;
    htmldb_application.g_page_text_generated := true;
    --htp.htmlOpen;
    --htp.headOpen;
    --htp.title('SQL to Excel Export');
    --htp.headCLose;
    --htp.bodyOpen;
    execute immediate 'alter session set nls_date_format=''dd-mon-yyyy'''; -- hh24:mi:ss''';
    DBMS_SQL Calls
    dbms_sql.parse(l_cursor,rtrim(p_sql,';'),dbms_sql.native);
    l_status := dbms_sql.execute(l_cursor);
    dbms_sql.describe_columns(l_cursor,l_col_cnt,l_desc);
    l_frow := l_desc.FIRST;
    l_lrow := l_desc.LAST;
    if l_col_cnt > 0 then
    FOR colind IN l_frow..l_lrow LOOP
    l_cols := l_cols||chr(9)||l_desc(colind).col_name;
    END LOOP;
    htp.p(ltrim(l_cols,chr(9)));
    end if;
    for i in 1 .. l_col_cnt loop
    if l_desc(i).col_type = 12 then
    dbms_sql.define_column(l_cursor,i,l_date);
    else
    dbms_sql.define_column(l_cursor,i,l_columnValue,4000);
    end if;
    end loop;
    --l_status := dbms_sql.execute(l_cursor);
    while (dbms_sql.fetch_rows(l_cursor) > 0) loop
    for i in 1 .. l_col_cnt loop
    if l_desc(i).col_type = 12 then
    dbms_sql.column_value(l_cursor,i,l_date);
    l_row := l_row||chr(9)||to_char(l_date,'DD-MON-YYYY HH24:MI:SS');
    else
    dbms_sql.column_value(l_cursor,i,l_columnValue);
    l_row := l_row||chr(9)||l_columnValue;
    end if;
    end loop;
    htp.p(ltrim(l_row,chr(9)));
    l_row := '';
    end loop;
    --htp.bodyclose;
    --htp.htmlclose;
    dbms_sql.close_cursor(l_cursor);
    exception
    when others then
    dbms_sql.close_cursor(l_cursor);
    htp.p(SQLERRM||chr(10)||p_sql);
    end SQL_TO_EXCEL;
    Any ideas on how I can get the spreadsheet to update from repeated calls to the PL/SQL?

  • Merge Statement in ABAP

    Dear Gurrus,
    i am having a trouble in using oracle merge statement in abap, the moment i use where clause in the bottom it  gives me an oracle error
    EXEC SQL.
      MERGE INTO SAP_GL_ACCOUNT@GETZDB a
      USING SKA1 b
        ON (A.gl_code= B.SAKNR)
      WHEN MATCHED THEN
        UPDATE SET a.posting_block =  B.XSPEB,
                   a.locked        =  B.XSPEA,
                   A.BALANCE_SHEET =  B.XBILK
         WHEN NOT MATCHED THEN
           insert   (gl_code,
                     DESCRIPTION,
                     posting_block,
                     locked,
                     balance_sheet)
          VALUES (b.SAKNR,'shadab',B.XSPEB,B.XSPEA,B.XBILK)
          where b. mandt = 950      I am talking about this line
             ENDEXEC.
    the Moment  i include WHERE clause in the botton before ENDEXEC it generates as error
    " Database error text........: "ORA-00904: "A3"."MANDT": invalid  identifier#ORA-02063: preceding line from GETZDB".
    although its a basic feature of Oracle to inclue where clauses in insert or update in merge, but here it is generating an error.

    Hello Shadab,
    As per my understanding of this oracle native sql code.
    everything is fine except the use of direct value i.e 950 .
    System is not able to process this value .
    This normally happens even in normal abap sql statements also.
    The better solution could be to declare a variable with the
    same data type as "mandt" and then pass this "950" value into that
    variable and then use this variable in the where clause instead of directly
    passing the value.
    i.e data:l_var type mandt vlaue '950'.
    The other option could be to use the same hard coded
    value but use this value in the where clause in quotations i.e.,
    '950' instead of 950.
    I hope this would solve your purpose, If not please reply me back.
    thanks,
    M.Naveen Kumar.

  • Loop statement in oracle

    SOurce Table
    ID ADDRESS1 ADDRESS2
    11 12 QA ST. 16 SELI ST.
    12 455 LANE 3222 ROGER LANE
    Target Table:
    ID TYPE ADDRESS1 ADDRESS2
    11 NORMAL XYZ st.
    11 HIGH ABC st.
    12 NORMAL TYU st.
    12 HIGH XCV st.
    Description of Problem:
    I have a source table in which ADDRESS1 pertains to Address1 column in target table where type= 'NORMAL' and ADDRESS2 pertains to Address 2 column in target table where type = 'HIGH'
    I want to update the target table using source table on ID so that Address column in target table is updated corresponding to the ADDRESS 1 AND ADDRESS 2 columns from source table.
    I am using the following code:
    MERGE
    INTO TARGET tgt
    USING SOURCE src
    ON (src.ID = tgt.ID)
    WHEN MATCHED
    THEN
    UPDATE
    SET tgt.address1 = src.address1
    where TGT.type = '=NORMAL'
    How can i update the address2 column in the target table where type = 'HIGH'
    in one shot.
    I dont want to write two seprate queries.
    I think i can use loop statement.
    Please Advice as how to use loop, else any other suggestion.
    Thanks

    user11018028 wrote:
    SOurce Table
    ID ADDRESS1 ADDRESS2
    11 12 QA ST. 16 SELI ST.
    12 455 LANE 3222 ROGER LANE
    Target Table:
    ID TYPE ADDRESS1 ADDRESS2
    11 NORMAL XYZ st.
    11 HIGH ABC st.
    12 NORMAL TYU st.
    12 HIGH XCV st.
    Description of Problem:
    I have a source table in which ADDRESS1 pertains to Address1 column in target table where type= 'NORMAL' and ADDRESS2 pertains to Address 2 column in target table where type = 'HIGH'
    I want to update the target table using source table on ID so that Address column in target table is updated corresponding to the ADDRESS 1 AND ADDRESS 2 columns from source table.
    I am using the following code:
    MERGE
    INTO TARGET tgt
    USING SOURCE src
    ON (src.ID = tgt.ID)
    WHEN MATCHED
    THEN
    UPDATE
    SET tgt.address1 = src.address1
    where TGT.type = '=NORMAL'
    How can i update the address2 column in the target table where type = 'HIGH'
    in one shot.
    I dont want to write two seprate queries.
    I think i can use loop statement.
    Please Advice as how to use loop, else any other suggestion.
    ThanksMaybe this? If you provide scripts for create tables and sample data this wouldn't be a guess :)
    MERGE
    INTO TARGET tgt
    USING SOURCE src
    ON (src.ID = tgt.ID)
    WHEN MATCHED
    THEN
    UPDATE
    SET tgt.address1 = case when TGT.type  = 'NORMAL' then src.address1 else tgt.address1 end
    ,   tgt.address2 = case when TGT.type != 'NORMAL' then src.address2 else tgt.address2 end

  • Delete internal table rows without using loop statement

    i have an internal table which consists of 100 records.
    i need to keep only first 5 records.
    without using the loop statement i need to delete the rest of the records. how can we achieve this result.
    i.e.  delete itab1 where  "recordno"  > 5.
    regards.
    ZG

    Hi,
    Delete itab [FROM idx1] [TO idx2] {Where (log_exp)]
    To delete several lines at once, you have to specify at least one of the additions FROM, TO, or WHERE. You can only use the additions FROM and TO with standard tables and sorted tables.
    Delete itab [FROM idx1]
    If you specify FROM, all the table rows from the table index idx1 onwards are included.
    Delete itab [TO idx2]
    If you specify TO, all the table rows from the table index idx2 onwards are included.
    PARAMETERS: p_carrid TYPE sflight-carrid,
                p_connid TYPE sflight-connid.
    DATA: BEGIN OF seats,
            fldate    TYPE sflight-fldate,
            seatsocc  TYPE sflight-seatsocc,
            seatsmax  TYPE sflight-seatsmax,
            seatsfree TYPE sflight-seatsocc,
          END OF seats.
    DATA seats_tab LIKE STANDARD TABLE OF seats.
    SELECT fldate seatsocc seatsmax
           FROM sflight
           INTO TABLE seats_tab
           WHERE carrid = p_carrid AND
                 connid = p_connid.
    LOOP AT seats_tab INTO seats.
      seats-seatsfree = seats-seatsmax - seats-seatsocc.
      MODIFY seats_tab INDEX sy-tabix FROM seats.
    ENDLOOP.
    ENDLOOP.
    SORT seats_tab BY seatsfree DESCENDING.
    DELETE seats_tab FROM 5.
    Thanks & Regards,
    ShreeMohan
    Edited by: ShreeMohan Pugalia on Jul 21, 2009 4:28 PM

  • Loop statement logic required!!!

    Dear Gurus,
    The following is used now. Need to change into Loop statement.
    Read the internal table t_ABC INTO w_ABC WITH KEY ....       "ABC is to collect all Successful Insertion
      IF sy-subrc NE 0.
        CLEAR w_ABC.
        Read the internal table t_XYZ INTO w_ABC WITH KEY ....
        IF sy-subrc EQ 0.
          PERFORM locktable.
          INSERT ABC FROM w_ABC.
          IF sy-subrc NE 0.
            w_failure = c_x.
          ENDIF.
          PERFORM unlocktable.
          APPEND w_ABC TO t_ABC.   "Here t_ABC will hv only all Successful Insertion records
          CLEAR w_ABC.
        ENDIF.
      ENDIF.
    Since there will be more than one record, I can't use READ Statement.
    How to use Loop? But it should not affect performance.
    My worry is that, if i use "Locking the table" and "Insert" inside Loop, then it will affect performance.
    Can any one please help me out?
    It's pretty urgent.
    Points will be rewarded immediately.
    Thanks & Regards,
    Neeraj

    Hi,
    Loop at t_abc INTO w_ABC .
    Read table t_XYZ INTO w_ABC WITH KEY ....
    IF sy-subrc EQ 0.
    PERFORM locktable.
    INSERT ABC FROM w_ABC.
    IF sy-subrc NE 0.
    w_failure = c_x.
    ENDIF.
    PERFORM unlocktable.
    APPEND w_ABC TO t_ABC. "Here t_ABC will hv only all Successful Insertion records
    CLEAR w_ABC.
    ENDIF.
    ENDIF.

  • Performance issue in Loop statement.

    Hi experts,
    I got an issue regarding performance in the loop statement. (IT_OUT_FINAL has huge amount of data.)
    LOOP AT it_out_final INTO wa_out_final.
    READ TABLE it_prdline_txt
    WITH KEY ydprodln = wa_out_final-prdline.
    IF sy-subrc = 0.
    wa_out_final-prdline = it_prdline_txt-ydvtext.
    MODIFY it_out_final FROM wa_out_final TRANSPORTING prdline.
    CLEAR: wa_out_final.
    ENDIF.
    read table i_sokna with key kunnr = wa_out_final-kunnr.
    if sy-subrc eq 0.
    wa_out_final-soreg = i_sokna-regio.
    MODIFY it_out_final FROM wa_out_final TRANSPORTING soreg.
    endif.
    read table i_sokna with key kunnr = wa_out_final-kunwe.
    if sy-subrc eq 0.
    wa_out_final-shreg = i_sokna-regio.
    MODIFY it_out_final FROM wa_out_final TRANSPORTING shreg.
    endif.
    clear : i_sokna,wa_out_final.
    ENDLOOP.
    Can you please help me , how to improve the performance in the above loop statement.
    Thanks,
    Revanth Kumar
    Moderator message: duplicate post locked.
    Edited by: Thomas Zloch on Jun 20, 2011 1:22 PM

    Hi,
    This one helped me in understanding the basics clearly. But I would like to further give you one example by which my question will be more clear to you and hence your further answer to it will help me in getting the idea about WHERE clause clarified.
    I was required to develop a report of all held docs by the SAP USER that were created through transaction FB60, the input obtained from user should be SAP USERNAME(obligatory).
    So the straight approach by me was that writing a SELECT-OPTIONS asking SAP USERNAME, and such username obtained from USER executing a report will be compared with the USERNAME stored in the column of table RFDT which stores all such held docs by a SAP USER that used transaction FB60 to temporarily hold it.
    So the approach used by me was using the select statement fetch all records from the column storing the SAP USERNAMES that have held docs using FB60 transaction and where clause is used to filter out only values matching the values obtained from user i.e. using SELECT-OPTIONS.
    So I was under the impression that WHERE clause can only be used in SELECT STATEMENT and not in LOOP AT...ENDLOOP.
    Now I hope my question is more clear to you. If I am not wrong, there can be two approaches,
    1) Using a SELECT statement containing the WHERE clause, fetch a resultset and then using LOOP...ENDLOOP. statement, display the output of the report using WRITE statement.
    i.e. SELECT...WHERE...ENDSELECT and then LOOP AT...ENDLOOP.
    2) Using SELECT statement, fetch all possible records and using LOOP...ENDLOOP. statement filter out the records using WHERE to match the resultset and display values in that resultset using WRITE statement
    i.e. SELECT...ENDSELECT and then LOOP AT...WHERE...ENDLOOP.
    Hope you will now be able to guide me better.
    Regards
    Ameet

  • Dynamic where clause with loop statement

    Hi all,
    is it possible to use a dynamic where clause with a loop statement?
    Can you please advise me, how the syntax needs to be?
    Thanks for your suggestions,
    kind regards, Kathrin!

    Hi Kathrin,
               If u are in ECC 6.0, please go through the code...
              REPORT  zdynamic_select.
    TYPES:
      BEGIN OF ty_sales,
        vbeln  TYPE vbak-vbeln,            " Sales document
        posnr  TYPE vbap-posnr,            " Sales document item
        matnr  TYPE vbap-matnr,            " Material number
        arktx  TYPE vbap-arktx,            " Short text for sales order item
        kwmeng TYPE vbap-kwmeng,           " Order quantity
        vkorg TYPE vbak-vkorg,             " Sales organization
        kunnr TYPE vbak-kunnr,             " Sold-to party
        netwr TYPE vbak-netwr,             " Net Value of the Sales Order
      END OF ty_sales.
    DATA :
      gt_sales TYPE STANDARD TABLE OF ty_sales,
      wa_sales TYPE ty_sales.
    DATA: ob_select TYPE REF TO cl_rs_where.
    DATA: ob_from   TYPE REF TO cl_rs_where.
    DATA: ob_where  TYPE REF TO cl_rs_where,
          gv_source TYPE abapsource.
    START-OF-SELECTION.
    *Step 1 : Prepare the select fields.
      PERFORM zf_build_select.
    *Step 2 : Build the from clause for the select
      PERFORM zf_build_from.
    *Step 3 : Build the where clause for the select
      PERFORM zf_build_where.
    *Step 4 : Execute the dynamic select
      SELECT (ob_select->n_t_where)
          FROM (ob_from->n_t_where)
            INTO CORRESPONDING FIELDS OF TABLE gt_sales
            WHERE (ob_where->n_t_where).
      LOOP AT gt_sales INTO wa_sales.
        WRITE :   /5 wa_sales-vbeln,
                  15 wa_sales-vkorg,
                  20 wa_sales-kunnr,
                  40 wa_sales-netwr,
                  50 wa_sales-posnr,
                  60 wa_sales-matnr,
                  70 wa_sales-arktx,
                  90 wa_sales-kwmeng.
      ENDLOOP.
    *&      Form  zf_build_select
    FORM zf_build_select .
      CREATE OBJECT ob_select.
    *Build the table name/field name combination
    *Add Sales order header fields
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'VBELN'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'VKORG'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'KUNNR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'NETWR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
    *Add Sales order item fields
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'POSNR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'MATNR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'ARKTX'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'KWMENG'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
    ENDFORM.                    " zf_build_select
    *&      Form  zf_build_from
    FORM zf_build_from .
      CREATE OBJECT ob_from.
    *Add opening bracket
      CALL METHOD ob_from->add_opening_bracket
      CLEAR gv_source.
    *Add the join condition.This can be made
    *fully dynamic as per your requirement
      gv_source = 'VBAK AS VBAK INNER JOIN VBAP AS VBAP'.
    *Add the where line
      CALL METHOD ob_from->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
    *Add the join condition.This can be made
    *fully dynamic as per your requirement
      gv_source = 'ON VBAKVBELN = VBAPVBELN'.
    *Add the where line
      CALL METHOD ob_from->add_line
        EXPORTING
          i_line = gv_source.
    *Add the closing bracket
      CALL METHOD ob_from->add_closing_bracket
    ENDFORM.                    " zf_build_from
    *&      Form  zf_build_where
    FORM zf_build_where .
      DATA :
      lv_field TYPE REF TO data,
      lv_field_low TYPE REF TO data,
      lv_field_high TYPE REF TO data.
      CREATE OBJECT ob_where.
    *Add the field VBELN : Sales Document
    *Use this method if you want to assign a single value to a field
    *Set the value for VBELN : Sales Document Number
    CALL METHOD ob_where->add_field
       EXPORTING
         i_fieldnm  = 'VBAK~VBELN'
         i_operator = '='
         i_intlen   = 10
         i_datatp   = 'CHAR'
       IMPORTING
         e_r_field  = lv_field.
    CALL METHOD ob_where->set_value_for_field
       EXPORTING
         i_fieldnm = 'VBAK~VBELN'
         i_value   = '0000120020'.
    *Use this method if you want to assign a range of values
    *Set a range for the Sales Document number
      CALL METHOD ob_where->add_field_between_2values
        EXPORTING
          i_fieldnm      = 'VBAK~VBELN'
          i_intlen       = 10
          i_datatp       = 'CHAR'
        IMPORTING
          e_r_field_low  = lv_field_low
          e_r_field_high = lv_field_high.
      CALL METHOD ob_where->set_2values_for_field
        EXPORTING
          i_fieldnm    = 'VBAK~VBELN'
          i_value_low  = '0000120020'
          i_value_high = '0000120067'.
    *Set the 'AND' Clause
      CALL METHOD ob_where->add_and.
    *Add the field MATNR : Material
      CALL METHOD ob_where->add_field
        EXPORTING
          i_fieldnm  = 'MATNR'
          i_operator = '='
          i_intlen   = 18
          i_datatp   = 'CHAR'
        IMPORTING
          e_r_field  = lv_field.
    *Set the value for the Material field
      CALL METHOD ob_where->set_value_for_field
        EXPORTING
          i_fieldnm = 'MATNR'
          i_value   = '000000000050111000'.
    *Set the 'AND' Clause
      CALL METHOD ob_where->add_and
    *Add the field VKORG
      CALL METHOD ob_where->add_field
        EXPORTING
          i_fieldnm  = 'VKORG'
          i_operator = '='
          i_intlen   = 4
          i_datatp   = 'CHAR'
        IMPORTING
          e_r_field  = lv_field.
    *Set the value for VKORG : Sales Organization
      CALL METHOD ob_where->set_value_for_field
        EXPORTING
          i_fieldnm = 'VKORG'
          i_value   = 'GMUS'.
    ENDFORM.                    " zf_build_where

  • Using Looping statements to loop images

    Hi Guys i posted a similar question to this before but i couldn't get anywhere using the method that was described to me. Im currently creating a Puyo Puyo game and im nearly done ive been working on this for about 2 months im still new to java. Anyway my question is, is that after my first two puyo images reach the bottom how would i go about having my next images load and then drop and then have that loop. I understand how to create a loop statement but i just don't understand what parameters i would need to put into it and what kind of loop statement i would need i.e. for loop, do loop etc... I really could use some help ive tried and gotten this far but im pretty stuck. I appreciate any help you can provide. Here is my code so far
    public class Puyo {
        public int x, y, color;
        public Puyo(int c, int x2, int y2) {
            color = c;
            x = x2;
            y = y2;
    import javax.swing.*;
    import java.awt.*; 
    public class DemoTest extends JPanel {
        public static void main(String[] args) { {
        JFrame frame = new JFrame("Puyo Puyo");
        frame.setContentPane(new PuyoAnimation()); 
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setSize(200,453);
        frame.setResizable(false);
        frame.setVisible(true);
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*; 
    import javax.swing.event.*;
    import java.util.Random;
    public class PuyoLogic extends JPanel {
       public static final int puyoEmpty=0;
      final int board_height = 12;
      final int board_width = 6;
      final int image_height= 32;
      final int image_width = 32;
      final int MAX_X = board_width*image_width;
      final int MAX_Y = board_height*image_height;
      private static final int DELTA_Y = 2;
      private static final int TIMER_DELAY = 20;
      Image images[];
      Puyo puyolist[][];
      Puyo current[];
      Puyo droppingBalls[];
      Timer pptimer;
      Random myRand= new Random();
      boolean keyRight,keyLeft,keyUp;
         public PuyoLogic() {
         super();
            puyolist = new Puyo[board_width][board_height];
            current = new Puyo[2];
            current[0] = new Puyo(myRand.nextInt(4), (board_width * image_width /2), 0);
            current[1] = new Puyo(myRand.nextInt(4), (board_width * image_width /2)+image_width, 0);
        // current[2] = new Puyo(myRand.nextInt(4), (board_width * image_width /2), 0);
       //     current[3] = new Puyo(myRand.nextInt(4), (board_width * image_width /2)+image_width, 0);
         images = new Image[4];
         images[0] = Toolkit.getDefaultToolkit().getImage("puyo_yellow.png");
         images[1] = Toolkit.getDefaultToolkit().getImage("puyo_blue.png");
         images[2] = Toolkit.getDefaultToolkit().getImage("puyo_green.png");
         images[3] = Toolkit.getDefaultToolkit().getImage("puyo_red.png");
         setFocusable(true);
         PuyoMove puyo_move = new PuyoMove(); // Make a new video game KeyListener
         addKeyListener(puyo_move);
         setBackground(Color.BLACK);
          pptimer = new Timer(TIMER_DELAY, new TimerAction());
          pptimer.start();
         public void setAnimation(boolean OnandOff){
            if (OnandOff) {
                pptimer.start(); 
            } else {
                pptimer.stop(); 
        public void NewBlock() {
        int newblock;
        int i,j;
        for(i=0; i<4; i++)
            for(j=0; j<4; j++)
            //puyolist[i][j] = new Puyo[2];
        current[0].x=board_width/2-2;
        current[0].y=0;
        public void puyoBoundsRight(Puyo[] current){
        if ((current[0].x + image_width <= MAX_X - image_width) && (current[1].x + image_width <= MAX_X - image_width)){
        current[0].x += image_width;
        current[1].x += image_width;
        public void puyoBoundsLeft(Puyo[] current){
        if ((current[0].x - image_width >= 0) && (current[1].x - image_width >= 0)){
        current[0].x -= image_width;
        current[1].x -= image_width;
       private class PuyoMove implements KeyListener {
         public void keyTyped(KeyEvent k){}
         public void keyReleased(KeyEvent k){}
         public void keyPressed(KeyEvent k){
            switch (k.getKeyCode()){
             case KeyEvent.VK_LEFT:
                 keyLeft = true;
                 break;
             case KeyEvent.VK_RIGHT:
                 keyRight = true;
                 break;
            public void paintComponent(Graphics g){
            super.paintComponent(g); 
            g.drawImage(images[current[0].color],current[0].x,current[0].y,this);
            g.drawImage(images[current[1].color],current[1].x,current[1].y,this);
           // g.drawImage(images[current[2].color],current[2].x,current[2].y,this);
            //g.drawImage(images[current[3].color],current[3].x,current[3].y,this);
            class TimerAction implements ActionListener {
            public void actionPerformed(ActionEvent e) {
              if (keyLeft){
                puyoBoundsLeft(current);
                keyLeft = false;
              else if (keyRight) { 
                puyoBoundsRight(current);
                keyRight = false;
              if (current[0].y + image_height <= MAX_Y && current[1].y + image_height  <= MAX_Y)
                 current[0].y += DELTA_Y;
                 current[1].y += DELTA_Y;
            else {
                   setAnimation(false);
               repaint();   
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    class PuyoAnimation extends JPanel {
       PuyoLogic pl;   
      public PuyoAnimation() {
           pl = new PuyoLogic();       
           JButton startButton = new JButton("Start");       
           JButton stopButton  = new JButton("Stop");
           startButton.addActionListener(new Start());
           stopButton.addActionListener(new Stop());
           JPanel button = new JPanel();
           button.setLayout(new FlowLayout());
            button.add(startButton);
            button.add(stopButton);
           this.setLayout(new BorderLayout());
           this.add(button, BorderLayout.SOUTH);
            this.add(pl,BorderLayout.CENTER);
        class Start implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                pl.setAnimation(true);
        class Stop implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                pl.setAnimation(false);
    }//endclass Edited by: Riz01 on Oct 14, 2009 1:35 PM

    Don't use a loop to do graphics, it will make your game unresponsive and possibly draw enough resources from your machine to make the entire system unresponsive. You make a javax.swing.Timer object and using the timing there to drive your animations.

  • Looping statements

    I am trying to set up a loop statement for the calculation of a mortgage amortization table. The formula I am using came from http://www.interest.com/hugh/calc/formula.html
    Here is what I have so far. It calculates the monthly payment given an array of interest rates and terms in years.
    public void monthlyPaymentCalc()
    Double P = new Double(amtLoan.getText()); // principal borrowed
    double X = P.doubleValue(); // variable X to represent the double value P
    double L = loan[0][0]; // array term years = 7 years
    double I = loan[0][1]; // array APR interest 0f 5.35
    double J = (I)/(12*100); // APR interest converted to monthly decimal
    double N = (L)*12; // convert years to payments per year (months)
    double D = (1+J); // simplify denominator for Math.pow
    double M = Math.abs(X * (J / (1 - ( Math.pow(D,-N)))));
    monthlyPayment.setText(" " + M);
    The calculations to be used in the loop are:     
    double H = X * J;           //current monthly interest
    double C = M - H;           //monthly payment minus monthly interest (principal paid)
    double Q = X - C;           //new principal balance
    X = Q;           //reset P to the new principal balance and start loop again
    I am very new at this, and have no clue how to set up a loop.. can anyone help me out with this?
    Thanks!
    visa798

    This should be very simple!
    //I am assuming that you want your loop to go round 12 times.
    for( int loopCount = 0 ; loopCount < 12 ; loopCount++ )
      //Put all that code which you want looped over here...
    }Hope this helps.
    Plutaurian

  • AW scripting question...loop statements

    Hello again Steve- everyone- I am trying to remember all the scripting options for looping statements. I know you can use a repeat/end repeat statement, but doesn't AW recognize a "while variable is true, do this"? Or a repeat while statement? Or repeat until a condition is true? I would appreciate a quick list of all the possible options for these looping statements that AW recognizes to get the dust off my brain.
    Thank you in advance for any input everyone, I always appreciate everyone's time!!
    Terry

    Authorware does support all of these, but they are named a little
    different, perhaps, than you are expecting.
    Open up the Functions window, and select the Language section. If you
    have a calc icon too, you can paste the right syntax into your calc by
    selecting the open calc, then double-clicking the appropriate language
    option.
    HTH
    Steve

  • SQL Statements in ABAP and meaning

    Hello Friends,
    Please, can anybody provide me a documentation on the different ABAP SQL statements and there usage/meanings.
    Thanks,
    Shreekant

    hi,
    goto abapdocu->abap Database access->open Sql you will get examples.
    for documnetation got se38->specify the command and press F1.
    SELECT:
    Put the curson on that word and press F1 . You can see the whole documentation for select statements.
    SELECT result
    FROM source
    INTO|APPENDING target
    [[FOR ALL ENTRIES IN itab] WHERE sql_cond]
    Effect
    SELECT is an Open-SQL-statement for reading data from one or several database tables into data objects.
    The select statement reads a result set (whose structure is determined in result ) from the database tables specified in source, and assigns the data from the result set to the data objects specified in target. You can restrict the result set using the WHERE addition. The addition GROUP BY compresses several database rows into a single row of the result set. The addition HAVING restricts the compressed rows. The addition ORDER BY sorts the result set.
    The data objects specified in target must match the result set result. This means that the result set is either assigned to the data objects in one step, or by row, or by packets of rows. In the second and third case, the SELECT statement opens a loop, which which must be closed using ENDSELECT. For every loop pass, the SELECT-statement assigns a row or a packet of rows to the data objects specified in target. If the last row was assigned or if the result set is empty, then SELECT branches to ENDSELECT . A database cursor is opened implicitly to process a SELECT-loop, and is closed again when the loop is ended. You can end the loop using the statements from section leave loops.
    Up to the INTO resp. APPENDING addition, the entries in the SELECTstatement define which data should be read by the database in which form. This requirement is translated in the database interface for the database system´s programming interface and is then passed to the database system. The data are read in packets by the database and are transported to the application server by the database server. On the application server, the data are transferred to the ABAP program´s data objects in accordance with the data specified in the INTO and APPENDING additions.
    System Fields
    The SELECT statement sets the values of the system fields sy-subrc and sy-dbcnt.
    sy-subrc Relevance
    0 The SELECT statement sets sy-subrc to 0 for every pass by value to an ABAP data object. The ENDSELECT statement sets sy-subrc to 0 if at least one row was transferred in the SELECT loop.
    4 The SELECT statement sets sy-subrc to 4 if the result set is empty, that is, if no data was found in the database.
    8 The SELECT statement sets sy-subrc to 8 if the FOR UPDATE addition is used in result, without the primary key being specified fully after WHERE.
    After every value that is transferred to an ABAP data object, the SELECT statement sets sy-dbcnt to the number of rows that were transferred. If the result set is empty, sy-dbcnt is set to 0.
    Notes
    Outside classes, you do not need to specify the target area with INTO or APPENDING if a single database table or a single view is specified statically after FROM, and a table work area dbtab was declared with the TABLES statement for the corresponding database table or view. In this case, the system supplements the SELECT-statement implicitly with the addition INTO dbtab.
    Although the WHERE-condition is optional, you should always specify it for performance reasons, and the result set should not be restricted on the application server.
    SELECT-loops can be nested. For performance reasons, you should check whether a join or a sub-query would be more effective.
    Within a SELECT-loop you cannot execute any statements that lead to a database commit and consequently cause the corresponding database cursor to close.
    SELECT - result
    Syntax
    ... lines columns ... .
    Effect The data in result defines whether the resulting set consists of multiple rows (table-like structure) or a single row ( flat structure). It specifies the columns to be read and defines their names in the resulting set. Note that column names from the database table can be changed. For single columns, aggregate expressions can be used to specify aggregates. Identical rows in the resulting set can be excluded, and individual rows can be protected from parallel changes by another program.
    The data in result consists of data for the rows lines and for the columns columns.
    SELECT - lines
    Syntax
    ... { SINGLE }
    | { { } } ... .
    Alternatives:
    1. ... SINGLE
    2. ... { }
    Effect
    The data in lines specifies that the resulting set has either multiple lines or a single line.
    Alternative 1
    ... SINGLE
    Effect
    If SINGLE is specified, the resulting set has a single line. If the remaining additions to the SELECT command select more than one line from the database, the first line that is found is entered into the resulting set. The data objects specified after INTO may not be internal tables, and the APPENDING addition may not be used.
    An exclusive lock can be set for this line using the FOR UPDATE addition when a single line is being read with SINGLE. The SELECT command is used in this case only if all primary key fields in logical expressions linked by AND are checked to make sure they are the same in the WHERE condition. Otherwise, the resulting set is empty and sy-subrc is set to 8. If the lock causes a deadlock, an exception occurs. If the FOR UPDATE addition is used, the SELECT command circumvents SAP buffering.
    Note
    When SINGLE is being specified, the lines to be read should be clearly specified in the WHERE condition, for the sake of efficiency. When the data is read from a database table, the system does this by specifying comparison values for the primary key.
    Alternative 2
    Effect
    If SINGLE is not specified and if columns does not contain only aggregate expressions, the resulting set has multiple lines. All database lines that are selected by the remaining additions of the SELECT command are included in the resulting list. If the ORDER BY addition is not used, the order of the lines in the resulting list is not defined and, if the same SELECT command is executed multiple times, the order may be different each time. A data object specified after INTO can be an internal table and the APPENDING addition can be used. If no internal table is specified after INTO or APPENDING, the SELECT command triggers a loop that has to be closed using ENDSELECT.
    If multiple lines are read without SINGLE, the DISTINCT addition can be used to exclude duplicate lines from the resulting list. If DISTINCT is used, the SELECT command circumvents SAP buffering. DISTINCT cannot be used in the following situations:
    If a column specified in columns has the type STRING, RAWSTRING, LCHAR or LRAW
    If the system tries to access pool or cluster tables and single columns are specified in columns.
    Note
    When specifying DISTINCT, note that you have to carry out sort operations in the database system for this.
    SELECT - columns
    Syntax
    | { {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ... }
    | (column_syntax) ... .
    Alternatives:
    1. ... *
    2. ... {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ...
    3. ... (column_syntax)
    Effect
    The input in columns determines which columns are used to build the resulting set.
    Alternative 1
    Effect
    If * is specified, the resulting set is built based on all columns in the database tables or views specified after FROM, in the order given there. The columns in the resulting set take on the name and data type from the database tables or views. Only one data object can be specified after INTO.
    Note
    If multiple database tables are specified after FROM, you cannot prevent multiple columns from getting the same name when you specify *.
    Alternative 2
    ... {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ...
    Effect
    A list of column labels col1 col2 ... is specified in order to build the resulting list from individual columns. An individual column can be specified directly or as an argument of an aggregate function aggregate. The order in which the column labels are specified is up to you and defines the order of the columns in the resulting list. Only if a column of the type LCHAR or LRAW is listed does the corresponding length field also have to be specified directly before it. An individual column can be specified multiple times.
    The addition AS can be used to define an alternative column name a1 a2 ... with a maximum of fourteen digits in the resulting set for every column label col1 col2 .... The system uses the alternative column name in the additions INTO|APPENDING CORRESPONDING FIELDS and ORDER BY. .
    http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm

  • Using loop statement in screen flow

    Hi Friends,
                    I have been working on the Module Pool for the last two weeks. But Iam unable to get the main difference between
    the   " LOOP WITH CONTROL TABCON "  and   "  LOOP AT ITAB WITH CONTROL TABCON CURSOR TABCON-CURRENT_LINE ".
    Please make me clear on this issue.
    Thanking you in advance,
    Regards,
    Murali Krishna

    This is copied from sap documentation
    link:[Table Controls in the Flow Logic|http://help.sap.com/saphelp_nw70/helpdata/en/9f/dbac5135c111d1829f0000e829fbfe/frameset.htm]
    LOOP WITH CONTROL ctrl.
    ENDLOOP.
    These statements create a loop pass through the step loop rows displayed on the screen.
    For PAI, they transfer the data of each group into the identically-named fields of the ABAP program or, vice versa,
    for PBO from the ABAP program into the step loop fields.
    In the LOOP-ENDLOOP loop, you can call modules that process the transferred data and for
    PBO read from an internal table, or for PAI import into an internal table.
    LOOP AT itab [INTO wa] WITH CONTROL ctrl.
    ENDLOOP.
    This statement assigns an internal table itab of the ABAP program to the table control and
    triggers a parallel loop run over the table control rows displayed on the screen and over the internal table itab.
    The additions INTO and WITH CONTROL are possible at the time of PBO, but not at PAI.
    The assignment of the loop to the table control takes place at PAI through the internal table.
    Using the INTO addition, the fields of the internal table itab are written to the work area wa at the time
    of PBO and the content of wa is transported, line by line, to the identically-named fields of the table control
    on the screen. Without the INTO addition, you must use an internal table with a header line.
    Then the content of the header line is transported line by line to the
    identically-named fields of the table control on the screen at the time of PBO.
    No module is required for filling the table control rows.
    Conversely, at the time of PAI, the internal table rows are not automatically
    filled with the contents of the table control rows. Instead, you must call a
    dialog module within the loop that modifies the table.

Maybe you are looking for

  • Why is my plugin blocked?

    why is my plugin blocked?

  • Unreliable Video performance in Premiere Pro CS5.5

    Hi there all ..Since rebuilding my PC to replace the original rotating OS disk with an SSD, I have been having all sorts of hassle with Premiere Pro CS5.5... in essence, video is often (but always) choppy although the frame counter advances smoothly.

  • I can't manually fade background music.

    This is a new problem for me.  I have always been able to add background music to a clip and fade the music in and out manually.  However, with my latest project this is not working.  I manually select a fade out point and the music just cuts out wit

  • Fast fwd & rewind buttons jamming on car stereo

    A few months ago I noticed that the fast forward and rewind buttons no longer functioned properly on my car stereo. I have an iphone 5 currently on IOS 7.1.2. I do not know if this loss of function coincided with a software update but the buttons wor

  • Diill through configuration BPC to ECC with multiple values for each dims

    Hi Guys, I have a situation where I want to pass on multiple values (ex: Country A is made up of multiple company codes 1000, 1010, 1020). I added these 3 values in member property maintenance for the node Country A under a propety I created called E