Condition statemsns

Hello Friends,
please give simple examples which invlove IF ,Else,endif,elseif

Hi,
When you branch conditionally, a processing block is executed or not based on the result of one or more logical conditions. ABAP contains two control structures for conditional branching.
The IF Control Structure
This control structure is introduced with the IF statement. The IF statement allows you to divert the program flow to a particular statement block, depending on a condition. The statement block concludes either with ENDIF, ELSEIF, or ELSE.
IF <condition1>.
  <statement block>
ELSEIF <condition2>
  <statement block>.
ELSEIF <condition3>.
  <statement block>
ELSE.
  <statement block>
ENDIF.
To formulate conditions in IF or ELSEIF statements, you can use any logical expression.
If the first condition is true, the system executes all the statements up to the end of the first statement block and then continues processing after the ENDIF statement. If the first condition is not true, the program jumps to the next ELSEIF statement and executes it like an IF statement. ELSE begins a statement block which is processed if none of the IF or ELSEIF conditions is true. The end of the last statement block must always be concluded by ENDIF.
You can nest IF control structures. However, the statement blocks must all end within the current processing block. So, for example, an IF - ENDIF block may not contain an event keyword.
DATA: TEXT1(30) VALUE 'This is the first text',
TEXT2(30) VALUE 'This is the second text',
TEXT3(30) VALUE 'This is the third text',
STRING(5) VALUE 'eco'.
IF TEXT1 CS STRING.
  WRITE / 'Condition 1 is fulfilled'.
ELSEIF TEXT2 CS STRING.
  WRITE / 'Condition 2 is fulfilled'.
ELSEIF TEXT3 CS STRING.
  WRITE / 'Condition 3 is fulfilled'.
ELSE.
  WRITE / 'No condition is fulfilled'.
ENDIF.
The output is:
Condition 2 is fulfilled.
Here, the second logical expression TEXT2 CS STRING is true because the string "eco" occurs in TEXT2.
The CASE Control Structure
This control structure is introduced with the CASE statement. The CASE control structure allows you to control which statement blocks are processed based on the contents of a data object.
CASE <f>.
  WHEN <f11> [OR <f 12> OR ...].
       <Statement block>
  WHEN <f21>.[OR <f 22> OR ...]
       <Statement block>
  WHEN <f31> [OR <f 32> OR ...].
       <statement block>
WHEN ...
  WHEN OTHERS.
       <statement block>
ENDCASE.
The statement block following a WHEN statement is executed if the contents of <f> are the same as those of one of the fields <f ij >. Afterwards, the program carries on processing after the ENDCASE statement. The statement block after the optional WHEN OTHERS statement is executed if the contents of <f> does not equal any of the <f ij > contents. The last statement block must be concluded with ENDCASE.
The CASE control structure is a shortened form of the following IF structure:
IF <f> = <f11> OR <f> = <f 12> OR <f> = ...
  <Statement block>
ELSEIF <f> = <f21> OR <f> = <f 22> OR <f> =...
  <Statement block>
ELSEIF <f> = <f21> OR <f> = <f 22> OR <f> =...
  <statement block>
ELSEIF <f> = ...
ELSE.
  <statement block>
ENDIF.
You can nest CASE control structures and also combine them with IF structures. However, they must always end with an ENDCASE statement within the current processing block.
DATA: TEXT1 VALUE 'X',
TEXT2 VALUE 'Y',
TEXT3 VALUE 'Z',
STRING VALUE 'A'.
CASE STRING.
WHEN TEXT1 OR TEXT2.
WRITE: / 'String is', TEXT1, 'OR', TEXT2.
WHEN TEXT3.
WRITE: / 'String is', TEXT3.
WHEN OTHERS.
WRITE: / 'String is not', TEXT1, TEXT2, TEXT3.
ENDCASE.
The output is:
String is not X Y Z
Here, the last statement block after WHEN OTHERS is processed because the contents of STRING, ‘A’, does not equal ‘X’, ‘Y’, or ‘Z’.
I think this will give u  an idea.
Regards.

Similar Messages

  • Error in creation of a condition record

    Hi to all, I've this error when I try to create a condition record :
    Implementation of Method FIELD_CHECK/DEFAULT_VALUE_SUGGESTION for BAdI /SAPCND/ROLLNAME for filter ZIUSERSTATUS is missing
    Message no. /SAPCND/MAINTENANCE719
    Diagnosis
    Implementation of BADI /SAPCND/ROLLNAME or method FIELD_CHECK/DEFAULT_VALUE_SUGGESTION is missing for the filter characteristic ZIUSERSTATUS.
    If, however, the implementation is correct (see BADI Interface Documentation) and active, there is an error in the condition maintenance layer.
    System Response
    An exception or error occurred because condition maintenance cannot check, convert or lock/unlock the fields of a condition record.
    Procedure
    Contact the department responsible for carrying out the missing implementation in the case of application fields in the customer namespace.  SAP is responsible for SAP fields which are set in the field catalog (/SAPCND/CTFC) and delivered, and if the field is supported as a possible field in a condition table. SAP is also responsible for the implementation of usage fields for SAP applications, just as with condition technique fields.
    In cases where SAP is responsible, contact your responsible support organization.
    Could someone help me please ?

    Hi I just put the coding:
    e_was_executed = 'X'.
    into every method and however it worked.
    Best Regards

  • IF Condition in RTF Help text

    Hi,
    I have RTF template which contains the field to display the column name. Below are my help text.
    COLUMN1 is my XML tag and displaying AQUA color in my excel output.
    <?COLUMN1?><xsl:attribute xdofo:ctx="block" name="background-color">Aqua</xsl:attribute>From above scenario, i need to add one more condition if there is no value in my XML tag then don't display the field in my excel output. For example. I have COLUMN1 and COLUMN2 XML Tag. Only COLUMN1 contains the value but COLUMN2 not. In my excel output the COLUMN2 value should not display.
    Thanks

    Please see if (How to make condition using XML tags to check NULL values in XML Publisher templates? [ID 414022.1]) helps.
    Also, see XML Publisher Guide which can be accessed via http://www.oracle.com/technetwork/documentation/applications-167706.html
    Thanks,
    Hussein

  • IF and ABS condition statement in BEX query designer

    Hi,
    I would like to ask the best way for me to produce an acceptable result from Excel IF and ABS Condition statement.
    The condition statement that I have on my Excel file is
    =IF((A2-B2)>0,ABS(A2-B2),0)
    I'm trying multiple times to reproduce this in BEX Query designer, unfortunately I'm getting a bad result or unacceptable formula.
    Anyone who could help me with my issue?
    Thanks,
    Arnold

    Hi Arnold,
    Thank you,
    Nanda

  • Classic report - Condition evaluated for every row

    APEX 4.2.2
    I am seeing something strange in a classic report region. A report started to fail at run-time with a strange error about bad syntax. When I run the page in debug mode, I see the following
    print column headings
    rows loop: 30 row(s)
    ...Execute Statement: begin wwv_flow.g_boolean := '' is not null;
    end;
    ......Result = false
    ...Execute Statement: begin wwv_flow.g_boolean := '' is not null;
    end;
    ......Result = false
    ...Execute Statement: begin wwv_flow.g_boolean := 'string with a embedded ' single quote' is not null;
    end;
    ......Result = true
    Looks like the APEX engine is evaluating a boolean expression after rendering and each and every row in the report. And for some strange reason, it is using a piece of data from my query's resultset and failing because of the bad syntax introduced due to the single-quote in the string.
    I have never seen this before. Any idea what is going on?
    Thanks

    Howdy Paul, sorry should have provided all the details. No, this is a standard generic column template. Ah, you are right, drat I should have looked closer. The template has use a condition to show either a highlighted row or normal one. Sorry for the false alarm, I can take it from here. Enjoy your flight :-)

  • I had 2 Apple IDs but now Apple implemented new conditions and i can't use one of them after 90 days using the prior one..! - "This Device Is Already Associated With an Apple ID"

    I have two Apple IDs because i travel frequently between Mexico and the US, and the apple stores offer different products, so i like to download music, movies and TV series from both sites.
    Apparently apple changed the conditions, becauise until a few days ago i could log our from one account and log in from my other one. Yesterday i was at Miami International Airport and wanted to download a few chapters from one of my TV series (Walking Dead) to watch on my way to Mexico City, but a pop up window came up saying "this device is already associated with an apple id". Curoiously, the ID to which i was connected to was precisely the one under which i had bought weeks ago the chapters i was wanting to download from the cloud. So it says i have to wait 90 days to change apple id.... weard! probably i accepted these terms when dowloading a new IOS version, so legally I'm dead in complaining, but why is it that if i am paying for all that i buy as a model citizen i am now blocked from jumping from one apple id to another one???? I can certainly buy another ipad and have one with one id and another one with the other, but is there any other way i can keep the two in just one device?? If i don't use i-could would anything change? This is really making me mad, and is the first time i have thought of moving our of mac products into samsung or others and buy my music and movies somewhere else where stupid restrictions like this one do not exist. Please help with a solution!

    OK, but in my ipad, the apple id i have in itues is already the one  iwant to have, but th one i used to sin in for i-coud is the other one. Any tip as to how to change the apple id for icloud and any idea how to know what apps i bought with the other apple id so as to delete them from my ipad to avoid being asked to enter another apple id every time they get updated? thanks!

  • How to Delete the condition record in CRM

    HI,
    Can you please help me how to delete the condition record from condition table in CRM.
    Please explain the usage of FM CRMXIF_CONDITION_SEL_DELETE with examples.
    I have also read the documention of the function module. How to use this FM for custom defined condition table.
    (this is the code given in Documentation)
    DATA-OBJECT_REPRESENTATION         = 'E'
    DATA-SEL_OPT-CT_APPLICATION              = 'CRM'
    DATA-SEL_OPT-OBJECT_TASK                    = 'D'
    DATA-SEL_OPT-RANGE-FIELDNAME        = 'PRODUCT_ID'
    DATA-SEL_OPT-RANGE-R_SIGN                  = 'I'    (Including)
    DATA-SEL_OPT-RANGE-R_OPTION           = 'EQ'
    DATA-SEL_OPT-RANGE-R_VALUE_LOW  = 'PROD_1'
    Thanks
    Shankar

    Hi Shankar,
    I am using the same CRMXIF_CONDITION_SEL_DELETE function module to delete condition record present in CRM.
    But it is giving me below error in the return table of the FM after i run the program. Can you please correct me if I am doing any thing wrong?
    Error in  lt_return: SMW3     CND_MAST_SEL_DEL_EXT_VALIDATE     CND_M_SD
    code:
    ls_range-fieldname = 'PRODUCT_ID''.
    ls_range-R_SIGN = 'I'.
    ls_range-R_OPTION = 'EQ'.
    ls_range-R_VALUE_LOW = '123456'.
    APPEND ls_range TO lt_range.
    MOVE lt_range TO ls_entry-SEL_OPT-range.
    ls_data-SEL_OPT-object_task = 'D'.
    ls_data-SEL_OPT-ct_application = 'CRM'.
    ls_data-object_representation = 'E'.
    CALL FUNCTION 'CRMXIF_CONDITION_SEL_DELETE'
      EXPORTING
        DATA          = ls_date
    IMPORTING
       RETURN        = lt_return
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      IMPORTING
        return = lt_ret.
    Edited by: Saravanaprasad Nadar on Jul 7, 2010 1:27 AM

  • SSRS Using Sum and = in a conditional operator

    Hi,
    Still getting to grips with SSRS so any help would be appreciated.
    My aim is to calculate a conditional field using the SSRS expression feature, the datasource is a shared dataset which i can't alter so i can't just go an alter the SQL query or anything.
    In SQL my query would be like this: SELECT COUNT(TotalHours) FROM TableName WHERE TotalHours <= 24
    Is there anyway to combined the Iff and Sum operator's to get a result like the above?
    At present all i managed to come up with is the below but obviously it's not returning the correct amount.
    =IIf(Fields!TotalHours.Value <= "24", Sum(Fields!TotalHours.Value), 0 )
    Please help!
    Edit: Please note that i'm not trying to sum a field based on a condition that relates to another column, i just need a sum of 'TotalHours' that are less than or equal to 24, please also note there is another field called category, each category needs a
    sum of the above.
    Regards,
    Marcus
    Plain_Clueless

    Hi Marcus,
    According to your description, you want to count [TotalHours] when the value of this field is less than 24, right?
    In your scenario, you could use the expression like below:
    =Sum(IIF(Fields!TotalHours.Value<=24,1,0))
    Please note don’t put this expression in the detail rows, you could refer to our test results:
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • Error in using a variable in filter condition in an Interface

    Hi All,
    I am using a variable in my interface in a filter condition. I have an EMP table of scott schema and want to pull all the records wiht hiredate date lying between 2 dates, incremental pull.For this I have created 2 variables and using them in the filter condition. I am getting an error inthe interface when I run in a package after declaring and refresing the variables.
    com.sunopsis.sql.SnpsMissingParametersException: Missing parameter
         at com.sunopsis.sql.SnpsQuery.completeHostVariable(SnpsQuery.java)
         at com.sunopsis.sql.SnpsQuery.updateExecStatement(SnpsQuery.java)
         at com.sunopsis.sql.SnpsQuery.executeUpdate(SnpsQuery.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execStdOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlI.treatTaskTrt(SnpSessTaskSqlI.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.g.y(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)
    Regards,
    Krishna

    Hi Krishna,
    What is the datatype of the Variable lastupdate ?
    In my case
    Variable
    Name : LastUpdateDate
    Datatype : Alphanumeric
    Action : Historize
    Query : select to_char(to_date(sysdate,'DD-MON-YY'),'DD-MON-YY') from sys.dual
    Then in filter I used
    EMP.HIREDATE>to_date('#LastUpdateDate','DD-MON-YY')
    Thanks
    Sutirtha

  • BAPI_CUSTOMERQUOTATION_CHANGE - error while changing a condition value

    Hallo Gurus,
    I am trying to use tshi BAPI BAPI_CUSTOMERQUOTATION_CHANGE to change a condition value of a condition record of a quotation.
    Every time I execute the BAPI, instead of the condition tyoe being changed, a new record is added to the list of conditions!
    Can someone please help!
    Thsi is my piece of code::
    itab_BAPISDH1X-UPDATEFLAG = 'U'.
    append itab_BAPISDH1X.
    itab_BAPICOND-ITM_NUMBER = '10'.
    itab_BAPICOND-COND_ST_NO = '31'.
    itab_BAPICOND-COND_COUNT = '00'.
    itab_BAPICOND-COND_TYPE = 'ZST3'.
    itab_BAPICOND-COND_VALUE = '15.00'.
    itab_BAPICOND-COND_UPDAT = 'X'.
    append itab_BAPICOND.
    itab_BAPICONDX-ITM_NUMBER = '10'.
    itab_BAPICOND-COND_ST_NO = '31'.
    itab_BAPICOND-COND_COUNT = '00'.
    itab_BAPICONDX-COND_TYPE = 'ZST3'.
    itab_BAPICONDX-UPDATEFLAG = 'X'.
    itab_BAPICONDX-COND_VALUE = 'X'.
    append itab_BAPICONDX.
    CALL FUNCTION 'BAPI_CUSTOMERQUOTATION_CHANGE'
      EXPORTING
        salesdocument                = p_vbeln
      QUOTATION_HEADER_IN          =
        quotation_header_inx         = itab_BAPISDH1X
      tables
        return                       = itab_BAPIRET2
       CONDITIONS_IN                =  itab_BAPICOND
       CONDITIONS_INX               =  itab_BAPICONDX
    Thanks!
    Mukta

    Hmm...
    Change the following....and check..
    itab_BAPICONDX-ITM_NUMBER = '10'.
    itab_BAPICOND-COND_ST_NO = '31'.
    itab_BAPICOND-COND_COUNT = '00'.
    itab_BAPICONDX-COND_TYPE = 'ZST3'.
    itab_BAPICONDX-UPDATEFLAG = 'X'.
    itab_BAPICONDX-COND_VALUE = 'X'.
    append itab_BAPICONDX.
    "change the above to.....
    ab_BAPICONDX-COND_TYPE = 'X'.
    append itab_BAPICONDX.
    The BAPICONDX.. should contain only X.. in the fields which you want to update.. try this change..and let us know if it works.
    Also have a look at the FUNCTION MODULE DOCUMENTATION for this bapi in SM37.
    Cheers...

  • Conditional show error in dashboard In OBIEE 11g

    Hi Gurus,
    I I have a dashboard prompt which is a radio button containing Month & Quarter. Also have 2 other prompts like DP_Month which will show months(201301,201302 ...) and DP_quarter which will show(2013Q1,2013Q2..). This 2 prompts will show conditionally based on based on 1st prompt selection(like Month or quarter) which is working properly.
    Suppose when I click Month I m getting 2nd month prompt and changed to Quarter and getting Quarter prompt..But when I move to 2nd page  Quarter prompt is selected but Month dropdown  is showing.
    Please suggest..
    Regards,
    Smita

    Hi Nagireddy, thanks for your reply.
    Is there any limit of values to extract in Dashboard prompt? i.e. when you use drop down list as Dashboard prompt, is there any limit of values to extract from database?
    In my local environment (instanceconfig.xml), there is limit of Rows to View and Download set to 20K, however I did not see anything related to the Dashboard Prompt.  

  • Free Goods with pricing condition (Urgent)

    Hi MM Expert,
    we have a probleme with free goods. because in PO item of free goods, there is no condition management (no Invoice entry) but we should manage some pricing condition for the item (spécifique condition relative to transport, ...).
    so are the any way of managing the expenses annex condition(transport charge, customs clearance charges,…) for the free goods in an item of Purchase Order ??
    thank's in advance.
    Said

    Hi,
    This is not possible to maintain the condition s for free goods because while creating the PO for free goods by selecting the free goods tad at item level, There is no Condition tab at Item detail .means you are not able to mainatin conditions.
    If you want to maintain the conditions ,you have to treat as a Normal scenarios .
    Regards
    Sanjay L

  • Making SKTO condition type as 0% in case of credits

    Hi All,
                  This is about the common scenario where in we give the credit back to the customer in normal practice as well in case of returns.
    The requirement is that whenever I create a credit memo (G2) or credit for returns (RE) , the SKTO should read as 0%. The catch here is that since the credit  memos are cretaed with reference to the orignal billing doc the SKTO condition which has the % discount copied from the payment terms is going to get copied in the credit memo request .
    Moreover there might be scenarios where the credit memo request is created independently w/o reference to  the original doc . So even in this case the SKTO is going to have  the % discount . It is because of this reason why I don't want to change/create any copy control routine from the original invoivce to the credit memo request doc.
    My question is :
    1. Is it possible to have the SKTO read as 0 % in case of credits ( G2 & RE) docs even though the credit memo request has a payment term which has the (xyz) % discount . ?
    2. If I am going to change the copy controls from CR to G2 or RE (returns) to RE (credit for returns), how
    would I need to do ?
    The Whole essence of this requirement is that my business doesn't want the cash discount (SKTO) to figure when they issue a credit.
    Thanks
    Sridhar

    Hi Lakshmi,
                            Thanks for your suggestion .But I have bottlenecks in both the cases:
    1. In case 1 if I have to change the pricing procedure I need to introduce 2 new pricing procedures as we have 2 different products and both of them use different pricing procedures. This is a viable solution ,but I need to spend most of the time convincing the business that it doesn't impact anything .
    2. In case 2 , I have 2 credit scenarios ,(i) normal credit memos (ii) credit for returns . I have  the F2 -G2 in VTFF,but there is no F2-RE as of now . So I might have to create this . SInce this both the billing types are standard, is it recommended to create F2 -RE in VTFF?. Please let me know .
    OR as said by Mr .Shivram , I am looking at the option of modifying the requirement 6 assigned to SKTO in the pricing procedure .
    Thanks
    Sridhar

  • Free goods condition records - Usage in Sales Order

    HI,
    I have so many condition records in various KOTN9xx tables, which are for issuing free goods. If I see a sales order item, that is a free good, how do I know, on what basis (based on which condition record, in which condition table) that free good was issued?
    Technically speaking: Similar to KONV table for storing transaction data on pricing, is there a table for storing transaction data on free goods?
    Thanks,
    Juwin

    Find the table number of the key combination of customer / material . & you can extract free goods condition records from this table.
    Search in SE11 with the table number.

  • How to change pricing Conditions in Sales order in change sales order bapi

    Hi Experts,
    How to change pricing Conditions in Sales order in change sales order bapi.
    I have used the 2 function modules bapi-changesalesorder and sd salesdocument change, But it is creating the new record , instead of changing the existing one, Could please assist regarding the same
    Thanks in Advance .
    NLN

    HI NLN
      I have just tried on my system and managed to overwrite the existing price by passing the following parameters.
      <b>Import Paramters:</b>
         SALESDOCUMENT - Sales Document Number
         ORDER_HEADER_INX - UPDATEFLAG as <b>'U'</b>.
         LOGIC_SWITCH - Import Structure - Pass 'X' to LOGIC_SWITCH-COND_HANDL.
      <b>Tables:</b>
         CONDITIONS_IN - ITM_NUMBER,
                         COND_COUNT, -> Condition counter same as KONV-ZAEHK generally it is <b>'01'</b>
                         COND_TYPE,
                         COND_VALUE,
                         CURRENCY.
         CONDITIONS_INX - ITM_NUMBER,
                          COND_COUNT,
                          COND_TYPE,
                          UPDATEFLAG as <b>'U'</b>,
                          CURRENCY.
       Hope i have clarified your query.
    Kind Regards
    Eswar

Maybe you are looking for

  • Bootcamp and windows 8(partition problem)

    I am trying to install windows 8 and until now with no sucess. The instalation by the bootcamp runs smoothly, but when I boot from the USB, start the instalation process on windows and it asks me what partition I want to install the windows, I try to

  • Get document url in SAX ContentHandler

    Hopefully a simple question, but how to get the name or URL of the current document handled by a SAX ContentHandler? I don't see this in the startDocument or startElement callbacks.

  • Portal logoff should Close or Exit from  the window

    Hi Friends, Please help me here, When user click on logoff or Exit from the portal the Window should be closed. (I disabled the popup message box , now I am trying to figured it out how to close the window) Please help me. Peter

  • Export part of the timeline

    Hi, Is it possible to mark in/out on the timeline and only export this part in PPRO CS3? Thanks in advance. /Ulf

  • Migration OAS 4.0.8. to 9i AS

    What should I do in order to migrate present applications from OAS 4.0.8 to 9i AS?