Re: control statement

Hi,
   How can i write this below code in  good programming practice.
IF P_MWSKZ = 'S0' OR
         P_MWSKZ = 'S1'  OR
         P_MWSKZ = 'S2'  OR
         P_MWSKZ = 'S3'  OR
         P_MWSKZ = 'S4'  OR
         P_MWSKZ = 'S5'  OR
         P_MWSKZ = 'S6'  OR
         P_MWSKZ = 'S7'  OR
         P_MWSKZ = 'S8'  OR
         P_MWSKZ = 'S9'.
      ENDIF.
rgds
p. krishna prasad

Hi,
If the values are continous..Then you can use ranges..
Example
RANGES: R_MWSKZ FOR BSEG-MWSKZ.
R_MWSKZ-SIGN = 'I'.
R_MWSKZ-OPTION = 'BT'.
R_MWSKZ-LOW = 'S0'.
R_MWSKZ-HIGH = 'S9'.
APPEND R_MWSKZ.
IF P_MWSKZ IN R_MWSKZ.
  WRITE: / 'TRUE'..
ENDIF.
Thanks,
Naren

Similar Messages

  • Is there a way to make state transitions/animations of a fl.control states - button for example ?

    Is there a way to make state transitions/animations of a fl.control states - button for example ?
    All I can do now is change the skin design and that's it, I can't animate between states like I can with Flash Builder skins. So is there a way to do that, any technique or I have to create a button component from scratch?
    Thanks!

    simplebuttons have upState etc properties you can use to assign movieclips to the 3 states.  you can use the currentFrame property of movieclps to (appear to) smoothly transition from one state to another.

  • Transaction control statements in loop

    for i in p_time_duration_rspm_spm.first..p_time_duration_rspm_spm.last
    loop
    insert into green.solids_aaqm_namp(sample_nr,time_duration_rspm_spm,monometer_reading,
         avg_flow,total_sampling_period,vol_air_sampled,
                             filter_paper_nr,cup_nr)
                   values(p_sample_nr,p_time_duration_rspm_spm(i),
                        p_monometer_reading(i),p_avg_flow(i),
                        p_total_sampling_period(i),p_vol_air_sampled(i),
                        p_filter_paper_nr(i),p_cup_nr(i));
    end loop;
    hallo,
    i am facing a problem in the insert statement.There is a table(3*6).the fields in the table are
    of number datatype.if any character is entered in any of those field a error message as to be
    displayed.
    and if a character is entered into second row, then the readings in the first row is inserted
    in to the table and then a error message is prompted.i want to know whether can we use the transaction control statements
    within the loop to avoid inserting only one row.if so, how?...is there any other way to implement the same at the form level
    before going the database.

    Hello,
    FORALL i in p_time_duration_rspm_spm.first..p_time_duration_rspm_spm.last SAVE EXCEPTIONS
    insert into green.solids_aaqm_namp(sample_nr,time_duration_rspm_spm,monometer_reading,
    avg_flow,total_sampling_period,vol_air_sampled,
    filter_paper_nr,cup_nr)
    values(p_sample_nr,p_time_duration_rspm_spm(i),
    p_monometer_reading(i),p_avg_flow(i),
    p_total_sampling_period(i),p_vol_air_sampled(i),
    p_filter_paper_nr(i),p_cup_nr(i));
    end loop;
    If wants Errors then
    errors := SQL%BULK_EXCEPTIONS.COUNT;
    dbms_output.put_line('Number of DELETE statements that failed: ' || errors);
    FOR i IN 1..errors LOOP
    dbms_output.put_line('Error #' || i || ' occurred during '||
    'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX);
    dbms_output.put_line('Error message is ' ||
    SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
    END LOOP;
    OR You can use as follows
    for i in p_time_duration_rspm_spm.first..p_time_duration_rspm_spm.last
    loop
    begin -- Newline Added
    insert into green.solids_aaqm_namp(sample_nr,time_duration_rspm_spm,monometer_reading,
    avg_flow,total_sampling_period,vol_air_sampled,
    filter_paper_nr,cup_nr)
    values(p_sample_nr,p_time_duration_rspm_spm(i),
    p_monometer_reading(i),p_avg_flow(i),
    p_total_sampling_period(i),p_vol_air_sampled(i),
    p_filter_paper_nr(i),p_cup_nr(i));
    EXCEPTION when OTHERS then -- Newline Added
    null; -- Newline Added
    end; -- Newline Added
    end loop;
    Bye
    Chitta

  • Control statement in internal tables

    hi experts,
    can any body will provide me the control statement of internal table.
                                                               thank you

    Hi,
    check this link
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9f1f35c111d1829f0000e829fbfe/content.htm
    Control Break Statements
    Control break statements are used to create statement blocks which process only specific table lines the LOOP – ENDLOOP block.
    You open such a statement block with the control level statement AT and close it with the control level statement ENDAT. The syntax is as follows:
    Table should be sorted when you use control-break statements
    You can break the sequential access of internal tables by using these statements.
    Syntax:
    At first.
    <Statement block>
    Endat.
    This is the first statement to get executed inside the loop (remember control break statements are applicable only inside the loop)
    So in this block you can write or process those statements which you want to get executed when the loop starts.
    At New carrid.
    Write:/ carrid.
    Endat.
    In this case whenever the new carrid is reached, carrid will be written.
    At End of carrid.
    Uline.
    Endat.
    In this case whenever the end of carrid is reached, a line will be drawn.
    At Last.
    Write:/ ‘Last Record is reached’.
    Endat.
    Processing of statements within this block is done when entire processing of entire internal table is over. Usually used to display grand totals.
    You can use either all or one of the above control break statements with in the loop for processing internal table.
    At end of carrid.
    Sum.
    Endat.
    In above case the statement SUM (applicable only within AT-ENDAT) will sum up all the numeric fields in internal table and result is stored in same internal table variable.
    Regards,
    Sruthi

  • Control statements

    When using control statements like AT FIRST...ENDAT.AT NEW (field).... ENDAT.
    Is it necessary to define the field (thru which we r going to group the records) as a first field in internal table?

    Hi,
         Control break statements are used to stop the control at a particular point.
    1. AT NEW f.
    2. AT END OF f.
    3. AT FIRST.
    4. AT LAST.
    Effect
    In a LOOP which processes a dataset created with EXTRACT , you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT . The sequence of statements which lies between them is then executed if a control break occurs.
    You can use these key words for control break processing with extract datasets only if the active LOOP statement is proceesing an extract dataset.
    The control level structure with extract datasets is dynamic. It corresponds exactly to the sort key of the extract dataset, i.e. to the order of fields in the field group HEADER by which the extract dataset was sorted .
    At the start of a new control level (i.e. immediately after AT ), the following occurs in the output area of the current LOOP statement:
    All default key fields (on the right) are filled with "*" after the current control level key.
    All other fields (on the right) are set to their initial values after the current control level key.
    Between AT and ENDAT , you can use SUM to insert the appropriate control totals in the number fields (see also ABAP/4 number types ) of the LOOP output area (on the right) after the current control level key. Summing is supported both at the beginning of a control level ( AT FIRST , AT NEW f ) and also the end of a control level ( AT END OF f , AT LAST ).
    At the end of the control level processing (i.e. after ENDAT ), the old contents of the LOOP output area are restored
    use control break on any fields
    chk this sample program
    REPORT YCHATEST LINE-SIZE 350.
    TABLES MARA.
    DATA : BEGIN OF ITAB OCCURS 0,
             MATNR LIKE MARA-MATNR,
             AMOUNT TYPE P DECIMALS 2,
           END OF ITAB.
    ITAB-MATNR = '12345'.
    ITAB-AMOUNT = '100.20'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-MATNR = '12345'.
    ITAB-AMOUNT = '100.20'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-MATNR = '3456'.
    ITAB-AMOUNT = '100.20'.
    APPEND ITAB.
    CLEAR ITAB.
    sort itab by matnr amount.
    LOOP AT ITAB.
      AT END OF AMOUNT. 
        WRITE : / ITAB-MATNR , ITAB-AMOUNT.
      ENDAT.
    ENDLOOP.
    Regards

  • Transactional control statements in trigger

    Hi,
      Transaction Control statement, which cannot be executed within a trigger body??why...explain with reason
    its helpful me..

    Ishan wrote:
    "a way you can actually make it work" .... seriously?
    Yes, I was serious. Why? What's wrong with that? Technically speaking, won't it work?
    This is not a way to make it work, it's a way to break an application/process
    Well !!! All the cases?
    Here's  a scenario
    I want to audit a table where if any change done by the user has to be tracked in an audit table, irrespective whether the change has now been rolled back in the main table. I want to see what change was done? How would I do it? Going by your logic of breaking application/process, I should never use trigger as  AUTONOMOUS_TRANSACTION. Am I right? How would I achieve it now?
    Your auditing/tracing code should be in a separate procedure and that procedure should be autonomous, so that the requirement to write autonomous data for that purpose is kept isolated from the trigger code.  Consider this scenario instead.  You want to write audit/trace information from your triggers, so you make the trigger autonomous and put in your code to write the audit/trace information.  Later on, someone who hasn't a clue comes along and decides they need to do something else in that trigger (well why write a new trigger when one already exists?) and they get it to write some data in relation to the data being created by the trigger.  Now you suddenly have a transactionally unsafe application, where this 'child data' can still be written and committed even if there's a problem in the main transaction.  By isolating auding/tracing away to it's own autonomous procedure, you make it clear that it's only the auditing/tracing that should be autonomous and prevent any problems from occuring inside the trigger itself.
    That's more of a way to write bad code that is transactionally unsafe and demonstrates a lack of understanding of database transactional processing or how the rdbms on the server processes commits and could potentially lead to write contention in the writer processes, of which many would be spawned if the number of inserts (in this example) was high.
    The above comment is based on the assumption(which, I never stated) that in whatever scenario my code would be implemented, it would ALWAYS break the process. There are scenarios where this code could be required.
    Here's a link from Oracle Documentation, that uses an example of creating a trigger with AUTONOMOUS_TRANSACTION. If it is a so bad example which "demonstrates a lack of understanding of database transactional processing", why would Oracle even mention it in their documentation?
    http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/sqloperations.htm#BABDHGAB
    And the answer is because there is a way to do it and it could actually be required, even though it's rare.
    I just showed OP, that it's not allowed directly and if required, it can be done as there is a way to do it. When to do it and what could be the consequences was never the scope of the question.
    Yes, and there's ways to jump off cliffs and kill youself, but I wouldn't recommend demonstrating how to do that to people just because it's possible.
    Just because it's in the oracle documentation doesn't always mean it's best practice.  A lot of the documentation was written a long time ago and best practices have changed as well as further functionality added, and Oracle has been known to make mistakes in their documentation too.  However in this example, it's using it for auditing purposes, so the idea was almost there, but they still haven't met best practices of keeping the auditing isolated, so their example is not the best.

  • Control statements in  loop s with where cond

    Hi All,
    I am using control statements in the loop which as where condition  , The program works fine but , there is warning message , Is it appropriate to still use .
    Thanks in advance
    Vinay

    below is the code .
    LOOP AT gt_data_table INTO gs_data_table WHERE cust IN s_cust
                                                  AND site IN s_plant
                                                  AND acc_grp = gv_acc_grp
                                                  AND commodity IN s_commd
                                                  AND season IN s_season.
          lv_partial_stk =  lv_partial_stk  +  gs_data_table-available_stk.
          lv_over_stk    =  lv_over_stk     +  gs_data_table-available_stk.
          IF NOT gs_data_table-available_stk IS INITIAL.
            APPEND gs_data_table TO gt_data_table1.
          ENDIF.
          lv_cust       =  gs_data_table-cust.
          lv_commodity  = gs_data_table-commodity.
          lv_season     = gs_data_table-season.
          AT END OF lv_str1 .
            IF gs_data_table-site_typ      = 'COUNTRY'.
              gs_cust_cntry_stk-cust        = gs_data_table-cust .
              gs_cust_cntry_stk-commodity   = gs_data_table-commodity.
              gs_cust_cntry_stk-season      = gs_data_table-season.
              gs_cust_cntry_stk-cntry_stk   = lv_partial_stk.
              APPEND gs_cust_cntry_stk TO gt_cust_cntry_stk.
            ENDIF.
            IF gs_data_table-site_typ     = 'PORT'.
              gs_cust_port_stk-cust       = gs_data_table-cust .
              gs_cust_port_stk-commodity  = gs_data_table-commodity.
              gs_cust_port_stk-season     = gs_data_table-season.
              gs_cust_port_stk-port_stk   = lv_partial_stk.
              APPEND gs_cust_port_stk TO gt_cust_port_stk.
            ENDIF.
            CLEAR lv_partial_stk.
          ENDAT.
          AT END OF lv_str.
            gs_cust_overall_stk-cust         = lv_cust.
            gs_cust_overall_stk-commodity    = lv_commodity.
            gs_cust_overall_stk-season       = lv_season.
            gs_cust_overall_stk-overall_stk  = lv_over_stk .
            CLEAR lv_over_stk.
            APPEND gs_cust_overall_stk TO gt_cust_overall_stk.
          ENDAT.
        ENDLOOP.
    Thanks Guys
    vinay

  • About at new  control statement

    hello everybody
                                I need a small information about  at new control ..like when i'm using this control to get every new vendor  details ...in the out put its coming the related data like ********** .why its comin like this .can i know .please help me out .
    thanks&regards
    Lavanya

    AT for group change
    Change of group when processing loops of extracts and internal tables.
    Syntax
    AT NEW <f>.
    AT END OF <f>.
    AT FIRST.
    AT LAST.
    AT <fg>.
    The statements are used to process group levels within a loop using an extract dataset or an internal table. They introduce statement blocks that must be closed with ENDAT. The statements between AT and ENDAT are only executed if the corresponding group change occurred.
    When ever you use the control events and display the data you get some scrapped values.
    So, to avoid it use <b>READ TABLE <table name> INTO <WA></b>. and then print the values.
    Regards,
    Pavan P.

  • MFC Custom static control state is always 4

    Hi,
    I am creating a custom static control, and want to load different bitmap for different state.
    I inherited CMyStatic from CStatic and override the below functions. And i created the static control using SS_NOTIFY macro. 
    I am getting the state of the static control is 4. Then i called staticCtrl..EnableWindow(TRUE),
    also the state is 4.
    Can some one please help, how to find the correct state of static control like, STN_ENABLED, STN_DISABLE,
    STN_CLICKED etc..
    //CMyStatic.cpp
    BEGIN_MESSAGE_MAP(CMyStatic, CStatic)
    ON_WM_DRAWITEM()
    END_MESSAGE_MAP()
    void CMyStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
    int state = lpDrawItemStruct->itemState;
    void CMyStatic::PreSubclassWindow()
    CStatic::PreSubclassWindow();
    ModifyStyle(0,SS_OWNERDRAW);
    //MyDlg.cpp
    staticCtrl.Create(L"",BS_FLAT |  WS_VISIBLE | SS_CENTER | SS_NOTIFY,CRect(20,20,100,100),this,1111111); //state:4
    staticCtrl..EnableWindow(TRUE); //State:4
    Can someone please help on this.
    Thanks

    Hi LokanathNayak,
    From your description, you add SS_NOTIFY style to your static control, so the parent windows will get the notification message, STN_ENABLED, STN_DISABLE, STN_CLICKED etc..
    You need to manually add the notify message handler. Something like this:
    afx_msg void OnClicked();
    afx_msg void OnDoubleClicked();
    afx_msg void OnEnabled();
    BEGIN_MESSAGE_MAP(CMFCStaticNotifyDlg, CDialogEx)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_STN_CLICKED(ID_STATIC, &CMFCStaticNotifyDlg::OnClicked)
    ON_STN_ENABLE(ID_STATIC, &CMFCStaticNotifyDlg::OnEnabled)
    ON_STN_DBLCLK(ID_STATIC, &CMFCStaticNotifyDlg::OnDoubleClicked)
    ON_BN_CLICKED(IDC_BUTTON1, &CMFCStaticNotifyDlg::OnBnClickedButton1)
    ON_BN_CLICKED(IDC_BUTTON2, &CMFCStaticNotifyDlg::OnBnClickedButton2)
    END_MESSAGE_MAP()
    void CMFCStaticNotifyDlg::OnClicked()
    TRACE(L"clicked");
    void CMFCStaticNotifyDlg::OnEnabled()
    TRACE(L"enabled");
    void CMFCStaticNotifyDlg::OnDoubleClicked()
    TRACE(L"double click");
    Best regards,
    Shu
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to add control statement in Ant build file

    I don't know where to publish this question.
    if here is not the right place, can you tell me?
    I want to use Ant to run a java program.
    but the program can only deal with one file each time.
    So, I want to get all files' name and run it in a "while" or "for" statement.
    Thanks

         JarOutputStream jos = // ...
         jos.putNextEntry(new JarEntry("directory/"));
         jos.closeEntry();
         jos.finish();
         jos.close();on the command line:
    jar -tf <your_jar_file.jar>

  • Problems with a result in a switch/case control statement

    I am having troubles with a switch/case statement in which I am trying to get a result returned from different operators. The problem is that the result always returns 0 no matter what I put in the driver class.
    The class where the result needs to be returned looks like this:
    public class Calculator
         private int num1;
         private int num2;
         private char operator;
         private int result;
         public Calculator(int num1, char operator, int num2)
              this.num1 = num1;
              this.operator = operator;
              this.num2 = num2;
         } // end constructor
         public int getNum1()
              return num1;
         public char getOperator()
              return operator;
         public int getNum2()
              return num2;
         public int getResult()
              return result;
         public int calculate()
              switch(operator)
                   case '+':
                        int result = num1 + num2;
                        break;
                   } // end case '+'
                   case '-':
                        int result = num1 - num2;
                        break;
                   } // end case '-'
                   case '*':
                        int result = num1 * num2;
                        break;
                   } // end case '*'
                   case '/':
                        int result = num1 / num2;
                        break;
                   } // end case '/'
                   case '%':
                        int result = num1 % num2;
                        break;
                   } // end case '%'
              } // end switch
              return result;
         public String toString()
              String message = (num1) + " " + (operator)
                                  + " " + (num2) + " " + "=" + " " + result + "\n";
              return message;
    } // end class
    The driver class looks like this:
    import javax.swing.JOptionPane;
    import java.lang.StringBuffer;
    public class CalculatorApp
         public static void main (String[] args) // begin main
              String choice = "";
              while (!(choice.equalsIgnoreCase("x"))) // begin while loop
                   String number1 = JOptionPane.showInputDialog(
                                  "Enter a positive integer: ");
                   String operatorInput = JOptionPane.showInputDialog(
                                  "Enter operator (+, -, *, /, %): ");
                   String number2 = JOptionPane.showInputDialog(
                                  "Enter another positive integer: ");
                   int num1;
                   char operator;
                   int num2;
                   num1 = Integer.parseInt(number1);
                   operator = operatorInput.charAt(0);
                   num2 = Integer.parseInt(number2);
                   Calculator calculator = new Calculator(num1, operator, num2);
                   String message = calculator.toString() + "\n"
                                       + "Press Enter to conitnue or 'x' to exit.";
                   choice = JOptionPane.showInputDialog(message);
              } // end while loop
              System.exit(0);
         } // end main
    any help would be wonderful! I don't know why the result returned is always 0 but it is. Thanks!
    dragwit

    The previous poster is correct. You never call the calculate method. If you don't call it, no one's going to call if for you. This stuff doesn't work by magic. I think you've misunderstood your prof's intent in this regard.
    However, it still won't work with the changes previously suggested, because declaring an int result in the calculate method will hide the instance field of the same name, which is what your getResult() method retrieves. Don't delare result at all in your calculate method.
    That said, it would be architecturally a lot better if the calculate method returned the result rather than storing it back into the instance.

  • Control Statement inside System.out.println

    I am printing something like this:
    System.out.println(parts1[0] + "|" + parts1[1]); Now, I want to keep a check i.e. if parts1[1] is say 3 I want to printout Hi and if parts1[1] is any other digit I printout Hello. [parts is obtained by using split method from data]
    Can I do it inside the print statement?

    Be judicious about this though. Unless the ternary expression and the overall argument to println are both very simple, you'll end up with an unreadable, unmaintainable mess. The only advantage to doing it all inside the println argument is compactness. If it gets unwieldy, break it up into separate statements, assign the end result to a variable, and print that.

  • Control statement

    i m using at new field statement inside the loop.
    whenever the data in first field changes i want to append tht whole line in another internal table.
    loop at it.
    at new field1.
    it1 = it.
    append it1.
    endat.
    endloop.
    except first field all other fields r displaying * .
    why..
    how to get the data.
    based on tht data i have to do some calculation.
    Thanks in advance.

    try this...may b helpful...
    data:begin of itab occurs 0,
          matnr like mara-matnr,
          maktx like makt-maktx,
         end of itab .
    data:begin of itab2 occurs 0,
          matnr like mara-matnr,
          maktx like makt-maktx,
          end of itab2.
    select maramatnr maktmaktx appending table itab
    from mara inner join makt on maramatnr = maktmatnr.
    data:wk_maktx like makt-maktx.
    loop at itab.
      wk_maktx = itab-maktx.
      at new matnr.
      clear itab2.
      endat.
      at end of matnr.
        move:itab-matnr to itab2-matnr,
             wk_maktx to itab2-maktx.
             append itab2.
      endat.
      endloop.

  • Control structure in loops.

    I want to do something like below done in Perl in Pl/Sql but am not getting to it.
    # Perl code
    while($i <5)
    ... DO SOMETHING
    if ($i == 3)
    # means that start the loop again with $i = 4.
    next;
    # The following lines will be skipped when the value of $i will be 3
    ... DO SOMETHING
    $i++;
    Similarly,
    I have some cursor in pl/sql and I open a loop.
    -- Pl/SQl code
    for rec in cursor_records loop
    ... DO SOMETHING
    if( rec.my_val = 3) then
    -- now, what is the control statement do i need to give here, similar to above like next.
    -- Means, when value of rec.my_val is 3, then the lines following the if loop will get
    -- skipped and loop will continue for value 4.
    end if;
    ... DO SOMETHING
    end loop;
    Thanks..

    Thanks all for their replies.
    Looks like we don't have a way something like next/continue in Pl/Sql.
    hi Dave,
    I cannot use the approach you have said in the first reply as
    if you closely see my code, I have DO_SOMETHING before the check condition
    and have DO_SOMETHING again after the check condition.
    Your reply1, solves if only I have DO_SOMETHING2, and not DO_SOMETHING1.
    hi Leo,
    I see two loops as an overhead and I really do not prefer this approach.
    There can be a case when when a cursor is taking sometime to fetch a million records
    from billions of records and then act on them.
    In such a case, running two of them is really an overhead.
    I think that I will have to live with <<GO_TO>> option.
    Anywz, Thanks all for their replies and their effort.

  • Passing multiple fields as addition to  "end at " statement

    Hi All
    I dont think I can pass multiple fields to END AT statement.
    I need to sum at end of few field values in table .what is the best method of acheving this.
    Thanks in Advance
    Regards
    Vinay Kolla

    have different control blocks, and make sure you sort on all of the fields which you are using the control statements.

Maybe you are looking for