Urgent!!!!Related To SUB-ROUTINES

Hi All,
I have 2 subroutines.My problem is that if a particular sub-routine is terminated in middle for any reason my second sub-routine should not get called.How can i know that?Please answer my question as soon as possible.
Useful answers will be rewarded with points.
Regards,
Chaitanya.
Message was edited by:
        LEELA KRISHNA SAI CHAITANYA

Hi leela,
you can use one global variable for this as flag.
ex:
data flag type c.
perform sub1.
if flag = 'X'.
perform sub2.
endif.
form sub1.
if (condition yes).
   flag = 'X'.
endif.
endform.
form sub2.
endform.
this will work well

Similar Messages

  • Select statement in a sub routine(For Sapscript)

    Hi,
    M unable to write select statement for my reqirement in Sap-script in Sub routine.
    My requirement is 1)"Your correspondent for quality" in main window of my form.
    For dis rule is as below
    "Get the 'changed by' value resord in table QCPR field AENDERER.For the same value found in tabe USR21 fiels BNAME,pick up the PERSUNUM value.For dis PERSUNUM value, found in ADRP feild NAME_TEXT the value for "Your Correspondent for Quality".
    2) For this PERSUNUM value found in ADCP-TEL_NUMBER the vakue for "Ph".
    3)For this PERSUNUM value found in ADCP-FAX_NUMBER the vakue for "FAX".
    4For this PERSUNUM value found in ADR6-SMTP_ADDR the vakue for "EMAIL".
    Please help me out it's urgent for me.I wil b waiting 4 ur reply.

    READ TABLE in_par WITH KEY 'QCPR-AENDERER'.
      CHECK sy-subrc = 0.
      MOVE in_par-value TO V_aenderer
    .  READ TABLE in_par WITH KEY 'USR21-BNAME.
      CHECK sy-subrc = 0.
      MOVE in_par-value TO V_bname
      SELECT SINGLE persnumber addrnumber
        INTO wa_usr21-persnumber wa_usr21-addrnumber
        FROM usr21
        WHERE bname = V_bname
    and <b>check field for this</b> = V_aenderer.
      CHECK sy-subrc = 0.
      SELECT SINGLE tel_number fax_number
        INTO adcp-tel_number adcp-fax_number
        FROM adcp
        WHERE addrnumber = usr21-addrnumber
          AND persnumber = usr21-persnumber.
      CHECK sy-subrc = 0.
      READ TABLE out_par WITH KEY 'ADCP-TEL_NUMBER'.
      CHECK sy-subrc = 0.
      out_par-value = adcp-tel_number.
      MODIFY out_par INDEX sy-tabix.
      READ TABLE out_par WITH KEY 'ADCP-FAX_NUMBER'.
      CHECK sy-subrc = 0.
      out_par-value = adcp-fax_number.
      MODIFY out_par INDEX sy-tabix.
      SELECT SINGLE smtp_addr
        INTO adr6-smtp_addr
        FROM adr6
        WHERE addrnumber = usr21-addrnumber
          AND persnumber = usr21-persnumber.
      READ TABLE out_par WITH KEY 'ADR6-SMTP_ADDR'.
      CHECK sy-subrc = 0.
      out_par-value = adr6-smtp_addr.
      MODIFY out_par INDEX sy-tabix.
    Regards

  • Urgent related to message type structure and proxy

    Hello,
    My outbound interface related message type structure is like this....
    message type name : MSg1
    Msg1
    x
    y
    Z
    (under z)
    a
    b
    c
    ok,Now in generating the proxy how to populate this structure.
    For example ...
    if Msg type is emp_profile_msg
    Emp_name
    Empno
    Department_name
    we use this code
    REPORT zblog_abap_proxy.
    DATA prxy TYPE REF TO zblogco_proxy_interface_ob.
    CREATE OBJECT prxy.
    DATA it TYPE zblogemp_profile_msg.
    TRY.
    it-emp_profile_msg-emp_name = 'Sravya'.
    it-emp_profile_msg-empno = '80101'.
    it-emp_profile_msg-DEPARTMENT_NAME = 'NetWeaver'.
    CALL METHOD prxy->execute_asynchronous
    EXPORTING
    output = it.
    commit work
    CATCH cx_ai_system_fault .
    DATA fault TYPE REF TO cx_ai_system_fault .
    CREATE OBJECT fault.
    WRITE :/ fault->errortext.
    ENDTRY.
    if message type consists structure inside strucutre ..then how to populate those sructure

    Hi Sunil,
    Please don't mind, but I think I already have posted the answer for this query and have provided some links
    Please see the below mail.
    urgent related to Mesage types and proxy
    Please let me know if you need anything else than the given info.
    I have one sample program where we have deal with these kind of sub-sturctures
    Thanks
    Swarup

  • How to on Debugging Mode for T-Code F110 from Script in Sub routine Pool Pr

    Hi Every one....
    I have done SAP-Script for Payment Vocher for T-code F110 ..I have a Sub Routine Program where I have few Form statements which is called by SAP - Script using Perform Statements, But my problem is when I set a break point in Sub Routine pool program, the out put is issuing with out Debugger ...
    Could any one plz suggest me wht to do???
    Help ful answers will be rewarded....
    Regards,
    sg

    Hi,
    First see if the 'Perform' statement is getting triggered in Script. To put a breakpoint in any script ( even if you do not know the form name, that is the best part ) is se38---->RSTXDBUG --->F8 & execute your pgm/Transaction. The control will wait in the form-debugger.
    I hope this helps,
    Regards
    Raju Chitale

  • How do we write the sub routines in smart forms?

    1) How do we write the sub routines in smart forms?
    2) What is the’ form interface’ in smart forms?
    3) Write down the path for writing for select queries in smart forms?
    4) How do we put dynamic page break in smart forms?
    5) in which system field contain the total page number of all forms in the currently processed print request in smart forms?
    6) What is the name of function module used to calling smart forms?
    1)     What is the functionality of function module ‘controal_form’?
    2)     How do we print the system date in this format ’15th Jan 2008’ on scripts?
    3)     What r the various print modes available in scripts?
    4)     What is the tcode for text element?
    5)     How do we draw horizontal line in scripts?
    6)     How can we suppress the leading zeros for a field in scripts?
    7)     In which system field is used to print current no page in scripts?
    Which f.m is used to reads text in sap scripts

    1) How do we write the sub routines in smart forms?
    after opening form see global definitions
    click on that there one tab called form routines inthat you can write subroutines logic.
    You can call in program lines .
    2) What is the’ form interface’ in smart forms?
    It is an interface between program and form .
    like function module we provide import,export,tables,exceptions
    Based on import and export parameters form will display for us.
    3) Write down the path for writing for select queries in smart forms?
    On window give right click in that command->programlines
    you can write all select  statements.
    4) How do we put dynamic page break in smart forms?
    you can define break point using break-point<>. syntax.
    5) in which system field contain the total page number of all forms in the currently processed print request in smart forms?
    SFSY-PAGE
    SFSY-JOBPAGES
    6) What is the name of function module used to calling smart forms?
    SSF_FUNCTION_MODULE_NAME
    =================
    1) What is the functionality of function module ‘control_form’?
    This function module is used to insert SAPScript control commands like NEW-PAGE etc from whithin the ABAP program.
    CALL FUNCTION 'CONTROL_FORM'
    EXPORTING
      COMMAND    =
    EXCEPTIONS
      UNOPENED   = 1
      OTHERS        = 3
    IF SY-SUBRC NE 0.
    MESSAGE ...
    ENDIF.
    2) How do we print the system date in this format ’15th Jan 2008’ on scripts?
    Use SET DATE MASK to change format of date display.
    3) What r the various print modes available in scripts?
    4) What is the tcode for text element?
    se91
    5) How do we draw horizontal line in scripts?
    &ULINE&
    6) How can we suppress the leading zeros for a field in scripts?
    &it_vbak-vbeln(Z)&
    7) In which system field is used to print current no page in scripts?
    &SYST-PAGE& of &SYST-FORMPAGES&
    Which f.m is used to reads text in sap scripts
    READ_TEXT functiomodule.
    Reward points

  • Dynamic TABLE parameter in Sub routine call

    Hi,
    Is it possible to have a dynamic TABLE parameter in a sub-routine call? The structure of the internal table will be different during different calls to the sub-routine.
    I have a subroutine which has the FM "HR_INFOTYPE_OPERATION" to update the infotype data for an Applicant. Now i want to call this subroutine for every Infotype update. So every time the structure of the internal table to be passed will vary depending on Infotype ( eg P0002 for Infotype 0002, p0006 for infotype 0006).
    Any pointers will be appreciated.
    Thanks in advance.

    Hi Navin,
    yes, why not.
    just use a generic type parameter, i.e.
    FORM process USING IT_00x type table IV_type typc.
    It depend what yout FORM shall do. If you pass the types name, you can dynamically assign to a field-symbol of the respective type.
    Regards,
    Clemens

  • How do i make this a sub routine

    I have a little script to drill down folders and add comments to every folder and ever file inside the parent folder. It works perfectly well when run but itself. This was based heavily on the script found by NovaScotian here http://discussions.apple.com/thread.jspa?messageID=2182916&#2182916
    I basically want to make this script into a sub routine, and i have tried various methods and havent been able to make it work.
    global the_comments
    global each_item
    global pete
    global ddp
    global ddp2
    set ddp to {}
    set ddp2 to {}
    set theLetter to "s"
    set newDroppedFiles to choose folder with multiple selections allowed
    to drilldown(afolder)
    tell application "Finder"
    set file_list to files of a_folder
    set folder_list to folders of a_folder
    end tell
    repeat with i in file_list
    processDrilledDownFile(i)
    tell application "Finder"
    set comment of pete to text of the_comments
    end tell
    end repeat
    repeat with i in folder_list
    copy i to end of ddp2
    drill_down(i)
    end repeat
    end drill_down
    on processDrilledDownFile(a_file)
    copy a_file to end of ddp
    end processDrilledDownFile
    set the_comments to (do shell script "/usr/bin/defaults read com.Rich.move " & theLetter & "Text")
    repeat with each_item in newDroppedFiles
    set pete to each_item
    tell application "Finder"
    set comment of each_item to text of the_comments
    end tell
    drill_down(pete)
    end repeat
    repeat with each_item in ddp
    tell application "Finder"
    set comment of each_item to text of the_comments
    end tell
    end repeat
    repeat with each_item in ddp2
    tell application "Finder"
    set comment of each_item to text of the_comments
    end tell
    end repeat
    regards
    Rich

    Your script already includes several subroutines, so the trick is separating those out first.
    Essentially your script consists of three elements - global declarations, your own subroutines and a run handler. Since there's no explicit 'on run', everything that's not inside a subroutine becomes the run handler.
    Therefore what you should do is strip out all the code that's not a global declaration or an existing handler and just wrap that in a new 'on subroutinename()... end subroutinename' block.
    For sanity's sake I'd also add a specific run handler to bind it all together.
    This means you'll end up with something like:
    <pre class=command>global the_comments
    global each_item
    global pete
    global ddp
    global ddp2
    on run
    my myNiftySubroutine()
    end run
    to drilldown(afolder)
    tell application "Finder"
    set file_list to files of a_folder
    set folder_list to folders of a_folder
    end tell
    repeat with i in file_list
    processDrilledDownFile(i)
    tell application "Finder"
    set comment of pete to text of the_comments
    end tell
    end repeat
    repeat with i in folder_list
    copy i to end of ddp2
    drill_down(i)
    end repeat
    end drill_down
    on processDrilledDownFile(a_file)
    copy a_file to end of ddp
    end processDrilledDownFile
    on myNiftySubroutine()
    set ddp to {}
    set ddp2 to {}
    set theLetter to "s"
    set newDroppedFiles to choose folder with multiple selections allowed
    set the_comments to (do shell script "/usr/bin/defaults read com.Rich.move " & theLetter & "Text")
    repeat with each_item in newDroppedFiles
    set pete to each_item
    tell application "Finder"
    set comment of each_item to text of the_comments
    end tell
    drill_down(pete)
    end repeat
    repeat with each_item in ddp
    tell application "Finder"
    set comment of each_item to text of the_comments
    end tell
    end repeat
    repeat with each_item in ddp2
    tell application "Finder"
    set comment of each_item to text of the_comments
    end tell
    end repeat
    end myNiftySubroutine</pre>
    There's just one other observation - most of the globals are not actually needed since you can just pass them as parameters to the subroutines.
    I'm also not sure what the purpose of the script is - the upshot seems to be that you're setting the comment of items in the Finder, however, since you:
    <pre class=command> set comment of pete to text of the_comments</pre>
    and pete is a global pointing to the folder you're processing, surely this sets the comment of the folder x times, where x is the number of files in the folder - in other words if there are 100 files in the folder, you set the comment of the folder 100 times and don't touch the files themselves. Is that what you intend?

  • Passing parametrs to Sub routines

    Hi all,
    Please tell me how to pass the Parameters  as message number and message id for an SUB ROUTINE.If possible please give me the sample code.
    Regards
    Ajay

    declare
    data : message_nm type  sy-msgno,
            sys_id type sy-repid.
    simply write rthe oerform AS
    perform sample_form using message_nm
                                            sys_id
    then in the form.
    form sample_form using message_nm type sy-msgno
                                            sys_id type sy-repid .
    endform.
    reward points if useful...
    Edited by: Rudra Prasanna Mohapatra on Jun 25, 2008 1:41 PM

  • Include or sub-routine in user-exit

    Hi all,
    i want to put  a sub-routine in my customer user-exit (CMOD).but i can not put the subroutine.
    can i put a subroutine or include statement in a user exit?
    correct answers will be rewarded.
    Thanks
    pabi

    You can make subroutine calls inside a User exit, only if the exit is part of a function pool. All the subroutines can be placed in an include in the function pool & can be called with a Perform Statement from the User Exit.
    ~Suresh

  • How do we define a sub-routine in a subroutine pool

    How do we define a sub-routine in a subroutine pool and how do we call the same in an executable program

    Hi
    Go to SE38.Create a program and in the program type select Subroutine pool.Inside this u can code for teh various subroutines or forms.
    For calling these forms these forms in ur main program refer below link:
    <u>http://help.sap.com/saphelp_nw04/helpdata/en/9f/db999535c111d1829f0000e829fbfe/content.htm</u>
    Sample code:
    Below is the subroutine pool used in the creation of the SAP Script:
    Program Name : Z689_SUBROUTINE
    Date          : 03/28/2007
    Author        : Sayee Manojnah Kasala
    Description  : This is the subroutine used for SAP Script,
                   Z689_SAPSCRIPT.It fetches customer details like
                    customer name & place
    PROGRAM  Z689_SUBROUTINE.
    Form GET_LAND1
    Fetches the country key
    *&      Form  get_land1
          text
         -->INTABLE    text
         -->OUTTABLE   text
    FORM get_land1 TABLES intable STRUCTURE itcsy
                          outtable STRUCTURE itcsy.
      DATA: v_kunnr LIKE kna1-kunnr,
            v_land1 LIKE kna1-land1,
            v_name1 LIKE kna1-name1.
      READ TABLE intable INDEX 1.
      v_kunnr = intable-value.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = v_kunnr
        IMPORTING
          output = v_kunnr.
      IF sy-subrc = 0.
        SELECT SINGLE land1
          FROM kna1
          INTO v_land1
          WHERE kunnr = v_kunnr.
        IF sy-subrc = 0.
          READ TABLE outtable INDEX 1.
          outtable-value = v_land1.
          MODIFY outtable INDEX 1.
        ENDIF.
        SELECT SINGLE name1
          FROM kna1
          INTO v_name1
          WHERE kunnr = v_kunnr.
        IF sy-subrc = 0.
          READ TABLE outtable INDEX 2.
          outtable-value = v_name1.
          MODIFY outtable INDEX 2.
        ENDIF.
      ENDIF.
      CLEAR: intable,outtable.
    ENDFORM.                                                    "get_land1
    Form GET_LANDX
    Fetches the Country Name
    *&      Form  get_landx
          text
         -->INTABLE    text
         -->OUTTABLE   text
    FORM get_landx TABLES intable STRUCTURE itcsy
                          outtable STRUCTURE itcsy.
      DATA: v_land1 LIKE kna1-land1,
            v_landx LIKE t005t-landx.
      READ TABLE intable INDEX 1.
      v_land1 = intable-value.
      IF sy-subrc = 0.
        SELECT SINGLE landx
          FROM t005t
          INTO v_landx
          WHERE land1 = v_land1 AND spras = 'E'.
        IF sy-subrc = 0.
          READ TABLE outtable INDEX 1.
          outtable-value = v_landx.
          MODIFY outtable INDEX 1.
        ENDIF.
      ENDIF.
      CLEAR: intable,outtable.
    ENDFORM.                    "get_landx
    It can be called as follows:
    PERFORM GET_LANDX IN PROGRAM Z689_SUBROUTINE
    USING &V_LAND1&
    CHANGING&V_LANDX&
    ENDPERFORM.
    Reward points if found useful.
    Thanks
    Vasudha
    Message was edited by:
            Vasudha L

  • Smart forms not displaying result from sub routine

    I am working on a smart form and need to display the description of the fabric code. Under Form Routines, I create a sub routine
    FORM fcc_values USING gv_fabrictext.
    which is supposed to store the description in gv_fabrictext. GV_FABRICTEXT has been declared in global data as char64. Then I call prior to displaying my table as
    perform fcc_values using gv_fabrictext.
    And then insert the field &gv_fabrictext& in cell but this does not display any result
    I know for sure that this sub routine works as I have tested it separately as a test program. Any ideas?

    1. put break point at ssf_function madulename and check field value.
    or
    2 fm_name export parameter ur not mentioned
    or
    3 global variable not defined properly
    go through above. still if u didnt get
    need program where the problem to find.
    Message was edited by:
            Deepa KN

  • Reg, sub routine

    how can u call a sub-routine from other programmes?

    Hi,
    Start of Content Area
    Naming Subroutines Locate the document in its SAP Library structure
    With the PERFORM statement, you can call subroutines which are coded in the same ABAP program (internal calls), or subroutines which are coded in other ABAP programs (external calls).
    You can also specify the name of the subroutine dynamically at runtime, and call subroutines from a list.
    Internal Subroutine Calls
    To call a subroutine defined in the same program, you need only specify its name in the PERFORM statement:
    PERFORM subr [USING    p1 p2... ]
                 [CHANGING p1 p2... ].
    The internal subroutine can access all of the global data of the calling program.
    Example
    REPORT demo_mod_tech_perform_int.
    DATA: num1 TYPE i,
          num2 TYPE i,
          sum  TYPE i.
    num1 = 2. num2 = 4.
    PERFORM addit.
    num1 = 7. num2 = 11.
    PERFORM addit.
    FORM addit.
      sum = num1 + num2.
      PERFORM out.
    ENDFORM.
    FORM out.
      WRITE: / 'Sum of', num1, 'and', num2, 'is', sum.
    ENDFORM.
    This produces the following output:
    Sum of          2 and          4 is          6
    Sum of          7 and         11 is         18
    In this example the subroutines addit and out are defined at the end of the program. addit is called by the program and out is called by addit. The subroutines have access to the global fields num1, num2 und sum.
    External Subroutine Calls
    The principal function of subroutines is for modularizing and structuring local programs. However, subroutines can also be called externally from other ABAP programs. In an extreme case, you might have an ABAP program that contained nothing but subroutines. These programs cannot run on their own, but are used by other ABAP programs as pools of external subroutines.
    However, if you want to make a function available throughout the system, you should use function modules instead of external subroutines. You create function modules in the ABAP Workbench using the Function Builder. They are stored in a central library, and have a defined release procedure.
    You can encapsulate functions and data in the attributes and methods of classes in ABAP Objects. For any requirements that exceed pure functions, you can use global classes instead of external subroutines.
    When you call a subroutine externally, you must know the name of the program in which it is defined:
    PERFORM subr(prog) [USING    p1 p2... ]
                       [CHANGING p1 p2... ] [IF FOUND].
    You specify the program name prog statically. You can use the IF FOUND option to prevent a runtime error from occurring if the program progdoes not contain a subroutine subr. In this case, the system simply ignores the PERFORM statement.
    When you call an external subroutine, the system loads the whole of the program containing the subroutine into the internal session of the calling program (if it has not already been loaded). In order to save memory space, you should keep the number of subroutines called in different programs to a minimum.
    Example
    Suppose a program contains the following subroutine:
    REPORT formpool.
    FORM header.
      WRITE: / 'Program started by', sy-uname,
             / 'on host', sy-host,
               'date:', sy-datum, 'time:', sy-uzeit.
      ULINE.
    ENDFORM.
    The subroutine can then be called from another program as follows:
    REPORT demo_mod_tech_perform_ext.
    PERFORM header(demo_mod_tech_formpool_1) IF FOUND.
    In this example, no data is passed between the calling program and the subroutine.
    Specifying Subroutines Dynamically
    You can specify the name of a subroutine and, in the case of external calls, the name of the program in which it occurs, dynamically as follows:
    PERFORM (fsubr)[IN PROGRAM (fprog)][USING    p1 p2... ]
                                       [CHANGING p1 p2... ]
                                       [IF FOUND].
    The names of the subroutine and the external program are the contents of the fields fsubr und fprogrespectively. By using the option IF FOUND, you can prevent a runtime error from being triggered if no subroutine with the name fsubr is found. If you omit the parentheses, this variant of the PERFORMstatement behaves like the static variant.
    Example
    Assume a program contains the following subroutines:
    PROGRAM formpool.
    FORM sub1.
      WRITE: / 'Subroutine 1'.
    ENDFORM.
    FORM sub2.
      WRITE: / 'Subroutine 2'.
    ENDFORM.
    Dynamic Subroutine Specification:
    PROGRAM form_test.
    DATA: progname(8) TYPE c VALUE 'FORMPOOL',
          subrname(8) TYPE c.
    subrname = 'SUB1'.
    PERFORM (subrname) IN PROGRAM (progname) IF FOUND.
    SUBRNAME = 'SUB2'.
    PERFORM (subrname) IN PROGRAM (progname) IF FOUND.
    This produces the following output:
    Subroutine 1
    Subroutine 2
    The character field progname contains the name of the program, in which the subroutines are contained. The names of the subroutines are assigned to the character field subrname.
    Calling Subroutines from a List
    You can call a subroutine from a list as follows:
    PERFORM idx OF subr1 subr2 ... subrn.
    The system calls the subroutine specified in the subroutine list in position idx. You can only use this variant of the PERFORMstatement for internal subroutine calls, and only for subroutines without a parameter interface. The field idx can be a variable or a literal.
    Example
    REPORT demo_mod_tech_perform_list.
    DO 2 TIMES.
      PERFORM sy-index OF sub1 sub2.
    ENDDO.
    FORM sub1.
      WRITE / 'Subroutine 1'.
    ENDFORM.
    FORM sub2.
      WRITE / 'Subroutine 2'.
    ENDFORM.
    This produces the following output:
    Subroutine 1
    Subroutine 2
    Regards,
    Chandru

  • Urgent : Relation b/w PROJ ,JEST ,JSTO.... tables?

    Hi Guys,
                  I am using these tables PROJ , JSTO , JEST , TJ30 , TJ30T and TJ02T.can anybody tell me how they are Related.I mean Primary Key Freign key Relationship.
                       In my program i have to download the data from these table based on Created date and Last Updatetd Date .Except PROJ table other tables are not having any date field. So how to download the data based on PROJ Table for all the other tables?
                              Very Very Urgent.Full points will be given for correct Answer.
    Thanks,
    Gopi.

    Hello Gopi,
    Please select the field OBJNR from PROJ table for a project not delete status.
    Than select all the active user/system status for that project. Active and Inactive status you will find from the FM STATUS_READ and STATUS_TEXT_EDIT
            SELECT SINGLE * FROM JSTO CLIENT SPECIFIED
                                      WHERE MANDT = MANDT
                                            AND   OBJNR = OBJNR.
            SELECT * FROM JEST CLIENT SPECIFIED
                               APPENDING TABLE JEST_TAB
                               WHERE MANDT = MANDT
                                      AND   OBJNR = OBJNR.
    Please let me know your exact requirement, so that I may help you in better way.
    Regards,
    A.Singh

  • SQL to include/exclude groupings based on set relations of sub-groupings

    Hello clever people,
    I am struggling to write SQL to enable me to include or exclude groupings (or even better sub groupings). It's taken a lot of SQL (using analytic functions) to get my data grouped as I wish (detail hopefully unimportant but basically trades grouped by date, desk, direction and asset).
    I now need to be able to include/exclude groupings depending on what I can see within them. I have managed to come up with logic based on the sets resulting from "subgrouping" my groupings into accounts, the set elements being the orders they have participated in. I believe that if I only include scenarios/groupings where the account order sets intersect yet are not equal, then I should have the report I need.
    Unfortunately I don't know how to code this in SQL.
    Columns 3, 4 and 5 of the below simplified table are information/desired, so if we take the first 3 columns as an existing "table", let's call it GROUPINGS (which I have created using a SQL query), how can I code this to include the groupings where subgroup sets intersect partially, and exclude the rest? I want to see groupings 4, 5 and 7 only.
    To get to the below has taken quite a lot of SQL already, so I'm keen to avoid having to join in back to itself if I can as the code will be a mess. I'm happy to post the underlying SQL but I'm not in my office currently so I can't now, I hope it isn't necessary anyhow.
    Very grateful for any help, I'm completely stuck.
    Thanks
    Jon
    P.s groupings/scenarios below taken in isolation, they aren't meant to have an effect on each other.
    Grouping
    Order
    Account
    Include Grouping in report
    Account Subgroup Order Sets
    Logic for Inclusion/Exclusion
    1
    1
    ABC
    F
    ABC {1}
    Business: Only one order for one account
    Maths: Only one Order Set (no intersection)
    2
    1
    ABC
    F
    ABC {1}, DEF {1}, GHI {1},
    Business: Only one order
    Maths: Where sets intersect they are equal
    2
    1
    DEF
    F
    2
    1
    GHI
    F
    3
    1
    ABC
    F
    ABC {1,2,3}
    Business: Only one order
    Maths: Only one Order Set (no intersection)
    3
    2
    ABC
    F
    3
    3
    ABC
    F
    4
    1
    ABC
    T
    ABC {1,2}, DEF {1}
    Business: Accounts are not consistent across orders and common account(s) exist across orders
    Maths: Where sets intersect they are not equal
    4
    1
    DEF
    T
    4
    2
    ABC
    T
    5
    1
    ABC
    T
    ABC {1,2}, DEF {1}, GHI {2}
    Business: Accounts are not consistent across orders and common account(s) exist across orders
    Maths: Where sets intersect they are not equal
    5
    1
    DEF
    T
    5
    2
    ABC
    T
    5
    2
    GHI
    T
    6
    1
    ABC
    F
    ABC {1,2,3}, DEF {1,2,3}
    Business: Common Accounts exist across orders but are consistent i.e. all accounts participate in all orders
    Maths: Where sets intersect they are equal
    6
    1
    DEF
    F
    6
    2
    ABC
    F
    6
    2
    DEF
    F
    6
    3
    ABC
    F
    6
    3
    DEF
    F
    7
    1
    ABC
    T
    ABC {1,3}, DEF {1,2}, GHI {2,3}
    Business: Common Accounts exist across orders but are inconsistent, i.e. not the same accounts appear in the related orders
    Maths: Where sets intersect they are not equal
    7
    1
    DEF
    T
    7
    2
    DEF
    T
    7
    2
    GHI
    T
    7
    3
    ABC
    T
    7
    3
    GHI
    T
    8
    1
    ABC
    F
    ABC {1,2}, DEF {1,2}, GHI {3,4}, JKL {3,4}
    Business: Common Accounts exist across orders but are consistent i.e. the same accounts participate in common orders
    Maths: Where sets intersect they are equal
    8
    1
    DEF
    F
    8
    2
    ABC
    F
    8
    2
    DEF
    F
    8
    3
    GHI
    F
    8
    3
    JKL
    F
    8
    4
    GHI
    F
    8
    4
    JKL
    F

    Swapping order_id and account_cd produces the same result
    with
    groupings as
    (select 1 grouping_id,1 order_id,'ABC' account_cd from dual union all
    select 2,1,'ABC' from dual union all
    select 2,1,'DEF' from dual union all
    select 2,1,'GHI' from dual union all
    select 3,1,'ABC' from dual union all
    select 3,2,'ABC' from dual union all
    select 3,3,'ABC' from dual union all
    select 4,1,'ABC' from dual union all
    select 4,1,'DEF' from dual union all
    select 4,2,'ABC' from dual union all
    select 5,1,'ABC' from dual union all
    select 5,1,'DEF' from dual union all
    select 5,2,'ABC' from dual union all
    select 5,2,'GHI' from dual union all
    select 6,1,'ABC' from dual union all
    select 6,1,'DEF' from dual union all
    select 6,2,'ABC' from dual union all
    select 6,2,'DEF' from dual union all
    select 6,3,'ABC' from dual union all
    select 6,3,'DEF' from dual union all
    select 7,1,'ABC' from dual union all
    select 7,1,'DEF' from dual union all
    select 7,2,'DEF' from dual union all
    select 7,2,'GHI' from dual union all
    select 7,3,'ABC' from dual union all
    select 7,3,'GHI' from dual union all
    select 8,1,'ABC' from dual union all
    select 8,1,'DEF' from dual union all
    select 8,2,'ABC' from dual union all
    select 8,2,'DEF' from dual union all
    select 8,3,'GHI' from dual union all
    select 8,3,'JKL' from dual union all
    select 8,4,'GHI' from dual union all
    select 8,4,'JKL' from dual
    got_account_cd_list as
    (select grouping_id,order_id,account_cd,
            listagg(account_cd, ',') within group (order by account_cd) over (partition by grouping_id,order_id) account_cd_list
       from groupings
    groupings_wanted as
    (select distinct 
            l.grouping_id
       from got_account_cd_list l
            inner join
            got_account_cd_list g
         on g.order_id > l.order_id
        and g.grouping_id = l.grouping_id
        and g.account_cd = l.account_cd
        and g.account_cd_list <> l.account_cd_list
    select g.grouping_id,g.order_id,g.account_cd,nvl2(w.grouping_id,'T','F') including
      from groupings g
           left outer join
           groupings_wanted w
        on w.grouping_id = g.grouping_id
    order by g.grouping_id,g.account_cd
    GROUPING_ID
    ORDER_ID
    ACCOUNT_CD
    INCLUDING
    1
    1
    ABC
    F
    2
    1
    ABC
    F
    2
    1
    DEF
    F
    2
    1
    GHI
    F
    3
    3
    ABC
    F
    3
    1
    ABC
    F
    3
    2
    ABC
    F
    4
    2
    ABC
    T
    4
    1
    ABC
    T
    4
    1
    DEF
    T
    5
    1
    ABC
    T
    5
    2
    ABC
    T
    5
    1
    DEF
    T
    5
    2
    GHI
    T
    6
    2
    ABC
    F
    6
    3
    ABC
    F
    6
    1
    ABC
    F
    6
    3
    DEF
    F
    6
    2
    DEF
    F
    6
    1
    DEF
    F
    7
    3
    ABC
    T
    7
    1
    ABC
    T
    7
    2
    DEF
    T
    7
    1
    DEF
    T
    7
    2
    GHI
    T
    7
    3
    GHI
    T
    8
    2
    ABC
    F
    8
    1
    ABC
    F
    8
    1
    DEF
    F
    8
    2
    DEF
    F
    8
    3
    GHI
    F
    8
    4
    GHI
    F
    8
    4
    JKL
    F
    8
    3
    JKL
    F
    Regards
    Etbin

  • Urgent - Cannot run sub query from VB 6

    Hello!
    I'm having a problem with my Oracle OLE DB connection in windows using Visual Basic 6.0 SP3.
    I can run normal queries just fine, but a correlated sub query like this:
    select A.col_a, (select col_b from Tab_B where id = A.id) from Tab_A A
    returns the following error:
    "ORA-00907: missing right parenthesis"
    But I'm able to run the query witout errors in Toad with the correct result!
    So basically, I cannot run a (correlated?) sub query via OLE DB...
    What am I doing wrong?? Is it a parameter that I need to set on the connection of command?
    I'm not using stored procedures, only plain text SQL.
    Very thankful for a quick answer, this is really urgent. If you have the possibility, please e-mail me at:
    [email protected]
    Thank you in advance.
    Best regards,
    Bnar Baban

    Hi!
    I'm running the latest version of Oracle OLE DB...when checking more in detail, it seems that the provider parses the code in a way, that makes the "(select" part of the sub statement be interpreted as a column name....when it does not find a right parenthesis, but a white space, it complains.
    I switched to Microsoft MSDAORA provider, and now it works perfectly...
    /Bnar

Maybe you are looking for

  • Goods Receipt for Inbound HU - WS_DELIVERY_UPDATE

    Hi All, I have a requirement to automate transaction VL60p to do GR for an inbound delivery with HU. Since this is a SAP enjoy transaction I can't use BDC and there doesn't seem to be a BAPI for this. I plan to use WS_DELIVERY_UPDATE, filling tables

  • Allowing Java Updater to run while using SRP/ The use of wildcards in a UNC path

    Recently I have deployed Software Restriction Policies to block certain paths from being able to run *.EXEs .  I have found this to be extremely successful and easy to manage with one exception: Java.  Here is what I have implemented as of now.  Plea

  • XML Publisher Doc Viewer Region error in Jdev but not on server

    I have created a OAF page using the XML Publisher Viewer region. When I run the page in JDev, click the Run button to generate the report, I get the following error: "An error encounterd either due to invalied Template details or due to null Data Inp

  • Another sound problem

    Hi I need some help getting the sound to work on logic express. I've tried looking through the manual but I couldn't find my answer. I know its probably something simple I'm forgetting to do so I would be thankful if some one could help me out with f

  • Horizontal scrolling. Is it possible?

    Hello. I'd like to create some pages for photos, similar to these http://dzineblog.com/2009/07/web-design-ideas-27-horizontal-scrolling-websites.h tml Is it possible? Thanks