SubVI with "Subroutine"-priority

It's known that it is impossible to call a non-"Subroutine"-SubVI from a
SubVI with "Subroutine"-priority. Actually subroutines are much faster,
because they do not create their own thread, as SubVIs with other
priority-levels do.
Is it possibly to force Labview not executing an own thread for every SubVI
that has a higher priority than "Subroutine" ?!?
Philipp

> It's known that it is impossible to call a non-"Subroutine"-SubVI from a
> SubVI with "Subroutine"-priority. Actually subroutines are much faster,
> because they do not create their own thread, as SubVIs with other
> priority-levels do.
> Is it possibly to force Labview not executing an own thread for every SubVI
> that has a higher priority than "Subroutine" ?!?
>
Actually things are a bit different than what you describe. SubVIs are set
to run in an execution system. All execution systems that are being used
will have threads created for them before the VI even begins to run. It
is the execution systems that define how many threads, not the VIs. Any and
all VIs that use an execution system share the threads. By default, each
execution system has one thread per priority per processor.
If each subVI uses a different execution system, and provided threading is
enabled, each subVI will be run by a different thread. This does cause
overhead due to the thread switches that the operating system must perform.
For that reason, it is usually best to leave the VIs in their default
setting -- running in the same thread as the caller. This avoids the thread
switch, and it allows for lots of freedom in later configurations. Here is
how. If you now have several tasks that you want to separate, you make them
subVIs and set them to different execution systems/priorities. Then any
subVI they call will inherit the execution system, the priority, and the
thread automatically without lots of reconfiguring or duplication of VIs.
Lastly, the subroutine is sort of an odd feature. It really isn't a
priority at all. A subroutine is a special way of compiling a VI that
turns off everything possible to make the VI run as efficiently as
currently possible. They always run in the thread of the caller, they
do not co-routine with other VIs of the same priority.
Subroutines turn off
debugging -- you cannot probe, set a breakpoint, or use highlighting
panel interaction -- the panel is not read or written to while the VI
runs ...
scheduling -- the VI cannot call VIs that aren't also subroutines, it cannot
have any asynchronous functions, sleeps, etc.
So, the best way to think of a subroutine is as a function call with as
little overhead as possible. Not all code can be turned into a subroutine,
and you should wait until the code is debugged before making subroutines.
It is also a good idea to use the profiler to point out the most commonly
called subVIs. If a subVI is only called two times, it is hardly worth
the effort of making it a subroutine. If a subVI is called 2,000,000 times,
then trimming off even a small amount per call can do wonders to speed up
your app.
Greg McKaskle

Similar Messages

  • Does a "subroutine priority" mean anything in an FPGA?

    Since a programmed FPGA is a collection of hardware logic strung together with potentially a great deal of it in parallel, does setting the execution priority properties of FPGA subVIs to "subroutine" really do anything? If you read the description of what a subroutine priority does, it says it devotes all the resources of an execution thread to the subroutine code. This to me implies time sharing of resources. But I don't think time-shared execution threads exist in an FPGA, or do they? Do any of the other possible execution priority levels mean anything to FPGA code?
    Solved!
    Go to Solution.

    Execution priorities have no effect in FPGA. Every subVI that does not require arbitration (ie, is either reentrant or used only once) is inlined into the main VI at compile time. As far as I know, execution priority has no effect on arbitration for those subVIs that do require it.

  • Subroutine Priority number of calls

    Subroutine Priority number of calls
    A normal VI can be only called ones at the same time. Is this by a VI with the settings Subroutine (Priority) the same?
    And by Multithreading ?
    (VI Properties --> Priority  --> Subroutine )
    Thanks
    Urs Mueller
    Solved!
    Go to Solution.

    OK you  are NOT talking about a re-entrant VI.
    YEs sub-routine priority for an Action Engine is just fine and if you step into the way-back-machine the NI RT course used to teach us to use an AE to interact with the time Critical loops since the sub-routine priority enabeld the "Skip If Busy" option  (and also here )for our sub-VI calls.
    The Skip If BUsy option was an early exception to the standrad data flow rule that the output from a sub-VI was required to progress beyonf that sub-VI.
    WHen that option is set (right-click the sub-VI to configure the call) LV would first check to see if that sub-VI was busy before attempting to call it. If it was busy the sub_VI would not be called and the wires coming from that sub-VI would contain the default-default of the data types.
    I use these often but in TC loops they are great since I can use a boolean returned by the sub-VI to tell me the call executed or not. Typicially the AE would provide the USer set-points or options (recieved from a GUI somewhere). If the Boolean was true, the sub-VI executed adn I should use its data. If it was false the sub_VI was skipped and I ignored the data from the AE.
    Works great last a long time.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Create at runtime a job to run at the central instance with high priority

    Hi All
    Using the function modules  (  job_open, job_submit and job_close )  or ( job_open, submit via job  jobname number jobcount, job_close) I need that this job runs in the central instance and with high priority.
    I would like to know how to  inform  it using the statements above?  How to pass the parameters to make the job run in the central instance with high priority?
    I would appreciate any help.
    Thanks in advance.
    João Gaia

    Hi
    I hadn't realized about the parameter TARGETSERVER of  the function module JOBCLOSE. I am going to make some tests.
    thanks in advance

  • How to build a subvi with a path

    Hi everybody
    I am using, in a main vi, a subvi with reentrant execution. Therefore I used a path to indicate the location of this subvi.
    It works very well.
    My problem is:
    When I build an application, and use it on another computer, the file.exe does not execute the subvi, since it does not find it on the specified path.
    How can I change this and manage to have this subvi run by the file.exe?

    Donc
    - le VI est chargé en mémoire dans l'application s'exécutant sur le second PC
    - son FP peut s'ouvrir
    - aucun message d'erreur lors de l'appel
    Mais
    - le VI ne fonctionne pas correctement comme il le fait sur le premier PC.
    En ce qui concerne LabVIEW, tout semble correct. Il s'agit peut-être d'une action spécifique de votre VI qui ne se fait pas de la même façon sur les 2 PC. Utilisez-vous des chemins pour localiser des fichiers?
    LabVIEW, C'est LabVIEW

  • Send mail through CL_BCS class with normal priority

    Hello guys!!!
    I'm trying to send email through CL_BCS class, and it's work fine!
    But, always sent with high priority, and I need to send whith normal priority.
    I tried this:
      DATA: o_send_request TYPE REF TO cl_bcs,
            o_document     TYPE REF TO cl_document_bcs.
      o_document = cl_document_bcs=>create_document(
                     i_type       = 'HTM'
                     i_text       = msgbody
                     i_subject    = subject
                     i_importance = '5' ).
    And this:
      CALL METHOD o_send_request->send_request->setu_priority
        EXPORTING
          i_priority = o_send_request->cp_priority_normal.
    Unfortunately, don't works.
    Any idea?
    Thanks!!!
    Kleber S. Kiefer

    Hi,
    Please try the following solution:
    * set mail importance to normal
    TRY.
    lo_document ?= lo_send_request->document( ).
    lo_document->set_importance( i_importance = '5' ).
    CATCH cx_sy_move_cast_error.
    ENDTRY.
    In addition, in the Alert framework, which send emails with high priority, it controls the document's importance and then send out the emails with high priority.
    * create send request, document etc..
        TRY.
            lo_document = cl_document_bcs=>create_document(
                                  i_type = l_texttype
                                  i_text = lt_text
                                  i_importance = '1'
                                  i_language = ls_langu_recipient-langu
                                  i_subject = l_subject_short
                                  i_length = l_so_obj_len ).

  • The default priority setting in Mail is set to "normal"  and is causing emails I send to be sent with red priority flag. How can I set default priority to low = no flag?

    The default priority setting in Mail is set to "normal"  and is causing emails I send to be sent with red priority flag.
    I have found the flags to reduce the priorty level manually to "low Priorty", but how can I set default priority to low = no flag?
    Thank you for advising,

    Try deleting the .plist.
    Quit the application.
    In Finder hold down the option/alt key while selecting the Go menu item. Select Library. Then go to Preferences/com.apple.mail.plist. Move the .plist to your desktop.
    Open the application and test. If it works okay, delete the plist from the desktop. 
    If the application is the same, return the .plist to where you got it from, overwriting the newer ones.
    If you want to make your user library permanently visible, run the below command in Applications/Terminal.
    chflags nohidden ~/Library/
    You will need to do that after any updates.

  • Create a subVI with fgv

    Hi,
    I Would like created a subVI with FGV of  my code in labview but  I cant see how to make the local variables to put them in subVI.
    Someone could show me an example with local variables in fgv pls?
    Best regards
     

    That VI really is something. How are you doing on LV Skills yourself? If you're new to LabVIEW I would highly suggest investing at least some time into the free courses and maybe even some money into a LabVIEW course.
    Here's a short list of the stuff available:
    3 Hour Introduction
    6 Hour Introduction
    LabVEW Basics
    Self Paced training for students
    Self Paced training beginner to advanced, SSP Required
    LabVIEW Wiki on Training
    Learning NI
    Getting Started with NI Products
    There you will learn many concepts of which I believe, FGVs, State Machine and Queue Driven State Machine (QDSM) should be particularly useful for you.

  • Retrieve messages with maximum priority

    Hi All,
    I need to retrieve messages from a queue with maximum priority. Hope i cannot set a MessageSelector query like this 'MAX(JMSPriority)'. Hence, i am creating two message consumers say consumerWithExpeditedPriority with MessageSelector string as 'JMSPriority > 4' and consumerWithNormalPriority with MessageSelector string as 'JMSPriority <= 4'.
    First i am attempting to receive through the first consumer and if the message is null, i am trying out the second.
    Is this the good way of implementation? Moreover, here i could classify only 2 levels of priority (normal and expedited) since i created two consumers. Actually, i needed all the 10 levels of JMSPriority to be handled out separately.
    Please provide your valuable suggestions
    Thanks and Regards,
    Balaji N

    Hi MA ...
    Is this account your main e-mail account or a alias ??
    Did you change your NEW e-mail account also by your e-mail provider (server) You have to delete the old e-mail address from that server to.
    Dimaxum

  • Administrator, Object Authorizer, Group User.. with Highest Priority

    Hello,
    I've searched the forum for this information but can't seem to find it.
    How do the priorities work in OIM?
    If I have a task that has to be approved by someone in a list of users, each with different priorities.. how does OIM evaluate that the user with Highest Priority should not get this task.. but instead the task should go to the second user with Highest Priority?
    I've been testing but it seems the task always goes to the same user, which is the one defined with priority 1, the others are ignored.
    For example.. if I have 20 tasks.. is there a way to make the first 15 (or whatever) go to the user with Highest priority and the other 5 to the user with the second highest priority?
    Thanks in advance

    Hi,
    You will need to write your custom task assignment adapter to do that.There is lot of post on how to write a task assignment adapter.
    Regards
    Nitesh

  • BDC for IW52 with giving Priority

    Hi All,
    I'll we very thankful if any one please help me in doing BDC for IW52 with giving Priority value .
    Actually I don't able to find Priority option in IW52.
    It'll be highly applicable if any one help me for this.
    Thanks

    Hi,
    I think you can make use of the FM "ALM_ME_NOTIFICATION_CHANGE" instead of IW52 BDC.
    Regards,
    Smart Varghese

  • How to save Jobs with different priority level in a Queue?

    Hi, Friends,
    I have a set of Job (see below) objects.
    I would make a queue: if they have the save priority level, first in and first out. this is easy to do by ArrayList. however, If they have different priority level, I would like make the Jobs with the highest level first out.
    How can I implemented this idea in Java?
    Regards,
    Youbin
    public class Job {
    private short _priorityLevel = 0;
    public void setPriorityLevel(short priorityLevel) {
    this._priorityLevel = priorityLevel;
    public short getPriorityLevel() {
    return _priorityLevel;

    Hi,
    Here is my test code, it works:
    public class Job implements Comparable{
    private int _priorityLevel=0;
    private String _jobDescription=null;
    public Job() {
    public void setPriorityLevel(int priorityLevel) {
    this._priorityLevel=priorityLevel;
    public int getPriorityLevel() {
    return this._priorityLevel;
    public void setJobDescription(String jobDescription) {
    this._jobDescription=jobDescription;
    public String getJobDescription() {
    return this._jobDescription;
    public int compareTo(Object obj) {
    return (this._priorityLevel-((Job)obj)._priorityLevel);
    import java.util.LinkedList;
    import java.util.Iterator;
    import java.util.Collections;
    import java.util.Collection;
    public class test {
    public test() {
    public static void main(String[] args) {
    Job job1 = new Job();
    job1.setJobDescription("Job1");
    job1.setPriorityLevel(2);
    Job job2 = new Job();
    job2.setJobDescription("Job2");
    job2.setPriorityLevel(2);
    Job job3 = new Job();
    job3.setJobDescription("Job3");
    job3.setPriorityLevel(2);
    Job job4 = new Job();
    job4.setJobDescription("Job4");
    job4.setPriorityLevel(1);
    Job job5 = new Job();
    job5.setJobDescription("Job5");
    job5.setPriorityLevel(1);
    Job job6 = new Job();
    job6.setJobDescription("Job6");
    job6.setPriorityLevel(1);
    LinkedList linkedList = new LinkedList();
    linkedList.addLast(job1);
    linkedList.addLast(job2);
    linkedList.addLast(job4);
    Iterator ite=linkedList.iterator();
    while (ite.hasNext()) {
    System.out.println(((Job)ite.next()).getJobDescription());
    System.out.println("---------");
    Collections.sort(linkedList);
    ite=linkedList.iterator();
    while (ite.hasNext()) {
    System.out.println(((Job)ite.next()).getJobDescription());
    System.out.println("---------");
    linkedList.addLast(job3);
    ite=linkedList.iterator();
    while (ite.hasNext()) {
    System.out.println(((Job)ite.next()).getJobDescription());
    System.out.println("---------");
    Collections.sort(linkedList);
    ite=linkedList.iterator();
    while (ite.hasNext()) {
    System.out.println(((Job)ite.next()).getJobDescription());
    System.out.println("---------");
    linkedList.addLast(job5);
    linkedList.addLast(job6);
    ite=linkedList.iterator();
    while (ite.hasNext()) {
    System.out.println(((Job)ite.next()).getJobDescription());
    System.out.println("---------");
    Collections.sort(linkedList);
    ite=linkedList.iterator();
    while (ite.hasNext()) {
    System.out.println(((Job)ite.next()).getJobDescription());
    }

  • SubVi with feedback nodes used more than once inside a While Loop

    All,
    I have a subvi that does a set of operations and uses 3 feedback nodes. I am using this subvi inside a While Loop a total of 4 times. I've noticed that all instances used share the same result at each corresponding feedback node but I would like to have an individual result from each of them. Is there an easy way to go around this problem? I have come up with ways to avoid this: a) create a different vi for each time the subvi was used. b) use global variables instead of feedback nodes. Is there any easier way to go around this issue?
    ExamplePlease note that both subvi's are the same) If on my first subvi I calculate a maximum value and get 1.29 (then goes to feedback node) on my second subvi i get 1.01 my feedback node at the second subvi still registers the maximum value to be 1.29. (and I want it to be 1.01!)
    Hope this is not too confusing, I've been scratching my head with this for a while, can't find the "easy" button. Thanks in advance.
    -Pop
    Im using 9.0.
    Solved!
    Go to Solution.

    Attaching the code would be helpful. Anyway, I am not sure how multiple feedback nodes are supposed to operate so I will defer that to others to answer. As far as being able to use distinct values or instances if you are using a subVI you could mark it as reentrant. That way each call to it will behave as it it were a copy of the VI and it will have its own memory space. This should include the feedback node. You may be ending up with a single subVI and in reality a single feedback node. If you need to pass data between calls than simply wire the data through. You could also use an Action Engine to store and retrieve values. An AE is a MUCH better solution than a global variable.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Problem with subroutine- need urgrnt help

    hai all,
    need help in subroutine.
    in a report program,
    i had calculated to get the total collection amount and need to generate a list for every day.
    on next day that collection amount must come as a poeninig balance at the top of the list.
    this i had done using two subroutines.
    i have to call the subroutine for opening balance for previous day's collection  first.  after that in have to calculate the todays collection.
    how can i have this please give me a suggession.
    thanks in advance.
    this is my report.
    i want the 'Progressive Total C/O ' from subroutine form f002_item_data. of today to be come in
    'Progressive Total B/F -
    ' ,106 w_total_bf.  of  the  subroutine form f001_progressive_total on next day..
    here is the code.....
    *& Report  ZVR023_COLL_STATEMENT                                       *
    report  zvr023_coll_statement           no standard page heading        .
          MODULE. MSD                                              *
          Objective :                                                   *
          Program   : Updates Tables (   )    Downloads data (  )       *
                      Outputs List   ( X  )                             *
          Date Created                                                  *
          Author                                                *
          Location                                                      *
          LDB                .....                                      *
          External Dependencies                                         *
    Amendment History                                                  *
    Who        Change ID    Reason                                      *
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯                                     *
    XXXXXXXXX  AADDMMYYYY Where XXXX = Developers Name................. *
               AA- Developers Initial ................................  *
          Includes                                                      *
    *INCLUDE   :                                                           *
          Tables                                                        *
    tables   : vbak,bsid,kna1,t001,adrc,vbrk,knvv.
          Types                    Begin with TY_                       *
    types : begin of ty_cust,
            belnr type bseg-belnr,
            wrbtr type bseg-wrbtr,
            xref1 type bseg-xref1,
            kunnr type kna1-kunnr, " sarang
            bschl type bseg-bschl,
            hkont type bseg-hkont,
            end of ty_cust.
    types : begin of ty_bp,
            kunnr type vbak-kunnr,
            bukrs type bseg-bukrs,
            budat type bkpf-budat,
            end of ty_bp.
    types : begin of ty_kna1,
            kunnr type kna1-kunnr,
            name1 type kna1-name1,
            ort01 type kna1-ort01,
            end of ty_kna1.
    types   : begin of ty_lst,
              vbeln      type vbrk-vbeln,                          " INVOICE NO
              fkart      type vbrk-fkart,
              posnr      type vbrp-posnr ,
              fkimg      type vbrp-fkimg ,                         " qty
              fkdat      type vbrk-fkdat,                          " date
              vkorg      type vbrk-vkorg,                          " sales org
              vtweg      type vbrk-vtweg,                          " division
              spart      type vbrk-spart,                          " distribution
              knumv      type vbrk-knumv,                          " Number of the document condition
              matnr      type vbrp-matnr ,
              med_prod   type jptmg0-med_prod,
              kunrg      type vbrk-kunrg,
              kwert      type konv-kwert,
              kbetr      type konv-kbetr,
              netwr      type vbrk-netwr,
    Address Details
             KUNRG type vbrk-KUNRG,
              name1      type kna1-name1,
              stras      type kna1-stras,
              pstlz      type kna1-pstlz,
    ***Added For Billing
             bukrs       type vbrk-bukrs,                          " Company code
             xblnr       type vbrk-xblnr,                          " Bill Ref
             ismpublication type mara-ismpublication,
    Condition Type
             kschl_zj01  type konv-kschl,
             kschl_zdis  type konv-kschl,
             kschl_znet  type konv-kschl,
             kwert_zj01  type konv-kawrt,                          " Base Condition
             kwert_zdis  type konv-kawrt,
             kwert_znet  type konv-kawrt,
             adrnr  type kna1-adrnr,
             end of ty_lst.
    types   : begin of ty_lst1,
              vbeln      type vbrk-vbeln,                          " INVOICE NO
              fkart      type vbrk-fkart,
              fkdat      type vbrk-fkdat,                          " date
              fkimg      type vbrp-fkimg,                          " qty
              kunrg      type vbrk-kunrg,                          " Payer
              fkimg_1    type vbrp-fkimg,                          " qty
              fkimg_2    type vbrp-fkimg,                          " qty
              fkimg_3    type vbrp-fkimg,                          " qty
              fkimg_4    type vbrp-fkimg,                          " qty
              fkimg_5    type vbrp-fkimg,                          " qty
              matnr      type vbrp-matnr,
              med_prod   type jptmg0-med_prod,
              kwert      type konv-kwert,
              kbetr      type konv-kbetr,
              netwr      type vbrk-netwr,
    Address Details
            KUNRG      type vbrk-KUNRG,
              name1      type kna1-name1,
              stras      type kna1-stras,
              pstlz      type kna1-pstlz,
    ***Added For Billing
             bukrs type vbrk-bukrs ,
             xblnr type vbrk-xblnr,
             ismpublication type mara-ismpublication,
    ****SPLIT FOR RATE
             kbetr_1   type   konv-kbetr,
             kbetr_2   type   konv-kbetr,
             kbetr_3   type   konv-kbetr,
    Condition Type
             kschl_zj01 type konv-kschl,
             kschl_zdis type konv-kschl,
             kschl_znet type konv-kschl,
             kwert_zj01 type konv-kawrt,                          " Base Condition
             kwert_zdis type konv-kawrt,
             kwert_znet type konv-kawrt,
             end of ty_lst1.
    types   : begin of ty_condition,
              kschl type konv-kschl,                                " Condition Type
              kwert type konv-kwert,                                " Condition Value
              knumv type konv-knumv,                                " Document Condi
              kposn type konv-kposn,
              kbetr type konv-kbetr,                                " Condition Rate
              end of ty_condition.
    types : begin of ty_bkpf ,
    belnr type bkpf-belnr,
    gjahr type bkpf-gjahr,
    bukrs type bkpf-bukrs,
    end of ty_bkpf.
          Constants                Begin with C_                        *
    *CONSTANTS:                                                            *
          Data                     Begin with W_                        *
    data     : w_cnt type i .
    *DATA     : W_DMBTR  TYPE BSID-DMBTR.   " Open Value
    *DATA     : W_KWERT TYPE  VBRP-FKIMG.   " Invoice Value
    *DATA     : W_QTY_CON TYPE  VBRP-FKIMG.   " QTY
    *DATA     : W_TO_QTY_CON TYPE  VBRP-FKIMG.   " QTY
    *DATA     : W_DIFF TYPE  BSID-DMBTR.   " W_DIFF Bt Open & Invoice
    *DATA     : W_DMBTR_CR  TYPE BSID-DMBTR.   " Cr Value
    *DATA     : W_DMBTR_DR  TYPE BSID-DMBTR.   " Dr Value
    *DATA     : W_DMBTR_TO  TYPE BSID-DMBTR.   " Total Value
    *DATA :     W_KDGRP(2) .
    *DATA  :    W_CNT_IS TYPE I.
    *DATA  :    W_CNT_IS1 TYPE I.
    *DATA  :    W_CNT_IS2 TYPE I.
    *DATA  :    W_CNT_FIRST TYPE I.
    *DATA  :    W_CNT_ITAB TYPE I.
    *DATA  :    W_CNT_FIRST1(2).
    *DATA  :    W_CNT_TAB(62),
              W_CNT_TAB_HEA(62),
    *data:           W_CNT_POS TYPE I.
    Variable for balance window
    data : w_open_bal type dmshb_x8,
           w_total_bf type dmshb_x8,
           w_sub_tot  type dmshb_x8,
           w_total_co type dmshb_x8,
           w_bill_bal type dmshb_x8,
           w_drn_bal type dmshb_x8,
           w_othr_chr type dmshb_x8,
           w_total_bal type dmshb_x8,
           w_coll_bal type dmshb_x8,
           w_unsd_cr  type  dmshb_x8, "Unsold Credit
           w_inceve  type  dmshb_x8, "Incentive
           w_cr_nt   type  dmshb_x8. "Cr Note
    data     : w_pos  type bseg-wrbtr.   " Total Value
    data     : w_neg  type bseg-wrbtr.   " Total Value
    data : w_du_start_date like sy-datum,
           w_du_end_date like sy-datum .
    **vARIABLE DEFINED FOR CONSOLIDATED WINDOW
    data    : w_prod_cnt type i .
    data    : w_prod_ch(2)  .
    data    : w_prod_rate type i .
          Infotypes                   ( HR Module Specific)             *
    *INFOTYPES :                                                           *
          Internal tables          Begin with IT_                       *
    data : it_bp type table of ty_bp with header line,
           it_bp1 type table of ty_bp with header line,
           it_bp2 type table of ty_bp with header line,
           it_bp3 type table of ty_bp with header line,
           it_kna1 type table of ty_kna1 with header line,
           it_cust type table of ty_cust with header line,
           it_cust1 type table of ty_cust with header line,
           it_bkpf type table of ty_bkpf with header line,
           it_cust2 type table of ty_cust with header line,
           it_cust3 type table of ty_cust with header line.
    data : it_pos like rfposxext occurs 1 with header line,
    it_check like rfposxext occurs 1 with header line,
    it_pos_bc1 like rfposxext occurs 1 with header line,
    it_pos_bc like rfposxext occurs 1 with header line,
    it_pos_nc like rfposxext occurs 1 with header line,
           it_pos1 like rfposxext occurs 1 with header line,
           it_sec like rfposxext occurs 1 with header line.
    data : it_bal like rfposxext occurs 1 with header line.
    data : w_text(100) type c.
    data : w_cnt1(3).
    data : l_date like mara-ismpublperiod .
    data : p_date1 like  jkpaz-jkpavon.
    data : l_day_c(2).
    data : l_month_c(2).
    data : l_base_yr_c(4).
    data : w_text1(100) type c.
    data : w_text2(100) type c.
          Field Symbols            Begin with FS_                       *
    *FIELD-SYMBOLS:                                                        *
    field-symbols:  type ty_condition.
          Insert                                                        *
    *INSERT   :                                                            *
          Select Options          Begin with SO_                        *
    selection-screen skip 1.
    selection-screen:  begin of block b1 with frame title text-001.
    select-options  :  so_bukrs for vbrk-bukrs no intervals no-extension obligatory  .
    select-options  :  so_kunrg for vbrk-vkorg no intervals no-extension obligatory,
                       so_vkbur for knvv-vkbur no intervals no-extension ,
                       so_fkdat for bsid-budat  no-extension obligatory ,
                       so_bdat1 for bsid-budat  no-display ,
                       so_bdat3 for bsid-budat  no-display ,
                       so_kunnr for kna1-kunnr no-display.
    selection-screen:  end of block b1.
          Parameters              Begin with PR_                        *
    *PARAMETERS     :                                                      *
    selection-screen begin of block b3 with frame title text-003.
    parameters pr_3 radiobutton group rad1.
    parameters pr_4 radiobutton group rad1.
    selection-screen end of block b3.
    selection-screen begin of block b2 with frame title text-002.
    parameters pr_1 radiobutton group rad.
    parameters pr_2 radiobutton group rad.
    selection-screen end of block b2.
    *INITIALISATION   :
          At selection-screen                                           *
    *AT SELECTION-SCREEN.
          S T A R T   O F   S E L E C T I O N                           *
    start-of-selection.
      if pr_3 is not initial.
    Code commented/added by Praveen on 20.07.2006
       SELECT kunnr INTO CORRESPONDING FIELDS OF TABLE it_bp1 FROM knvv
                                       WHERE vkorg IN so_kunrg
                                         AND kunnr GE '0004000000'
                                         AND kunnr LE '0004999999'.
        select kunnr into corresponding fields of table it_bp1 from knvv
                                        where vkorg in so_kunrg
                                          and aufsd <> '01'
                                          and kunnr ge '0004000000'
                                          and kunnr le '0004999999' .
                                         and
                                         PLTYP ne 'HB'.
    *ends here
      endif.
      if pr_4 is not initial.
        clear so_kunnr[].
        clear so_kunnr.
        so_kunnr-sign = 'I'.
        so_kunnr-option = 'BT'.
        so_kunnr-low =  '0001000000'.
        so_kunnr-high = '0001999999'.
        append so_kunnr.
        so_kunnr-sign = 'I'.
        so_kunnr-option = 'BT'.
        so_kunnr-low =  '0002000000'.
        so_kunnr-high = '0002999999'.
        append so_kunnr.
        so_kunnr-sign = 'I'.
        so_kunnr-option = 'BT'.
        so_kunnr-low =  '0007000000'.
        so_kunnr-high = '0007999999'.
        append so_kunnr.
    Code commented/added by Praveen on 20.07.2006
        select kunnr into corresponding fields of table it_bp1 from knvv
                                        where vkorg in so_kunrg and
                                            kunnr in so_kunnr and
                                            vkbur in so_vkbur.
                                       AND kunnr GE '0001000000'
                                       AND kunnr LE '0001999999'   .
        select kunnr into corresponding fields of table it_bp1 from knvv
                                           where vkorg in so_kunrg and
                                               aufsd <> '01' and
                                               kunnr in so_kunnr and
                                               vkbur in so_vkbur.
                                       AND kunnr GE '0001000000'
                                       AND kunnr LE '0001999999'   .
    ends here
      endif.
      if pr_1 = 'X'.
        perform cust_prog.
        perform cust_line.
        perform f001_progressive_total.
        perform f002_item_data.
      elseif pr_2 = 'X'.
        perform cust_line.
        perform f002_item_data.
      endif.
    *&      Form  cust_prog
          text
    form cust_prog.
      clear it_bp3[].
      p_date1 = so_fkdat-low.
      call function 'Z_VF053_DATE_GET_YEAR_MONTH'
        exporting
          i_date  = p_date1
        importing
          e_dd    = l_day_c
          e_month = l_month_c
          e_year  = l_base_yr_c.
      ranges so_bdat2 for bsid-budat.
      clear : so_bdat3[].
      if l_day_c > 01.
        l_day_c = '01'.
        concatenate   l_base_yr_c l_month_c l_day_c     into l_date.
        so_bdat2-low = l_date.
        so_bdat2-high = so_fkdat-low - 1.
      else.
        so_bdat2-low = '00000000'.
        so_bdat2-high = '00000000'.
      endif.
      so_bdat2-sign = 'I'.
      so_bdat2-option = 'BT'.
      append so_bdat2 to so_bdat3.
      select kunnr bukrs budat into corresponding fields of table it_bp3 from bsid
                                         for all entries in it_bp1
                                         where bukrs in so_bukrs
                                           and kunnr = it_bp1-kunnr
                                           and budat in so_bdat3.
    select kunnr bukrs budat
    appending corresponding fields of table it_bp3
    from bsad
    for all entries in it_bp1
    where bukrs in so_bukrs
    and kunnr = it_bp1-kunnr
    and budat in so_bdat3.
      sort it_bp3 by kunnr .
      delete adjacent duplicates from it_bp3 comparing kunnr.
      sort it_bp3 by kunnr .
      clear w_total_bf.
    endform.                    "cust_prog
    *&      Form  cust_line
          text
    form cust_line.
      clear it_bp[].
      select kunnr bukrs budat
      into corresponding fields of table it_bp
      from bsid
      for all entries in it_bp1
      where bukrs in so_bukrs
      and kunnr = it_bp1-kunnr
      and budat in so_fkdat.
      select kunnr bukrs budat
      appending corresponding fields of table it_bp
      from bsad
      for all entries in it_bp1
      where bukrs in so_bukrs
      and kunnr = it_bp1-kunnr
      And budat in so_fkdat.
      sort it_bp by kunnr .
      delete adjacent duplicates from it_bp comparing kunnr.
      sort it_bp by kunnr .
    endform.                    "cust_line
    *&      Form  f001_progressive_total
          text
    form f001_progressive_total.
      if not it_bp3[] is initial.
        clear : w_text ,w_cnt,p_date1,l_base_yr_c, l_month_c,l_day_c,l_date.
       w_cnt1 = sy-tabix .
       CONCATENATE w_cnt1 '  Feaching Data  '  INTO w_text.
       CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
           text = w_text.
        ranges so_bdat2 for bsid-bldat.
        clear : so_bdat1[].
        p_date1 = so_fkdat-low.
        call function 'Z_VF053_DATE_GET_YEAR_MONTH'
          exporting
            i_date  = p_date1
          importing
            e_dd    = l_day_c
            e_month = l_month_c
            e_year  = l_base_yr_c.
        if l_day_c > 01.
          l_day_c = '01'.
          concatenate   l_base_yr_c l_month_c l_day_c     into l_date.
          so_bdat2-low = l_date.
          so_bdat2-high = so_fkdat-low - 1.
        else.
          l_day_c = so_fkdat-low.
          so_bdat2-low = l_date.
          so_bdat2-high = '00000000'.
        endif.
        so_bdat2-sign = 'I'.
        so_bdat2-option = 'BT'.
        append so_bdat2 to so_bdat1.
        export so_bdat1 to memory id 'DATE1'.
        export it_bp3 to memory id 'IT_BP3'.
        clear : so_bdat1, it_bp3.
        submit  z_rfitemar1
                with x_aisel = 'X'
                with x_norm = 'X'
                with dd_bukrs-low = so_bukrs-low                "#EC *
                and return.
        clear : it_pos[], it_pos .
        import it_pos from memory id 'zit_pos'.
        free memory id 'zit_pos'.
        delete it_pos where blart <> 'DZ'.
    Here Plz Clear all the varible to avoid overlap
        clear : w_open_bal,w_du_start_date,w_du_end_date.
        select belnr bukrs gjahr into corresponding fields of table it_bkpf
        from bkpf  for all entries in it_pos where belnr = it_pos-belnr and gjahr = it_pos-gjahr
    and bukrs = it_pos-bukrs and xreversal = ' '.
    endif.
        loop at it_pos.
          clear it_bkpf.
          read table it_bkpf with key bukrs = it_pos-bukrs belnr = it_pos-belnr gjahr = it_pos-gjahr.
          if sy-subrc eq 0.
            append it_pos to it_check.
          endif.
        endloop.
        it_pos[] = it_check[].
    ***opening bal
    since runtime error is coming while summing the alternate way is being used ... done by jayakumar on 11 10 06
       LOOP AT it_pos .
         SUM .
         w_open_bal = it_pos-dmshb .
         EXIT .
       ENDLOOP .
        loop at it_pos .
       read table it_cust3 with key belnr = it_pos-belnr.
       it_pos-dmshb = it_cust3-wrbtr.
          w_open_bal = w_open_bal + it_pos-dmshb .
        endloop .
        if w_open_bal < 0 .
          w_open_bal = w_open_bal * -1.
        endif.
        w_total_bf = w_total_bf + w_open_bal.
    endif.
      write :20 'Progressive Total B/F -
    ' ,106 w_total_bf.
      skip 1 .
    endform.                    "f001_progressive_total
    *&      Form  f002_item_data
          text
    form f002_item_data.
      if not it_bp[] is initial.
        select * into corresponding fields of table it_kna1 from kna1
                              for all entries in it_bp
                              where kunnr = it_bp-kunnr .
        export so_fkdat to memory id 'DATE'.
        export it_bp to memory id 'IT_BP'.
        clear : so_fkdat, it_bp.
        submit  z_rfitemar1
                with x_aisel = 'X'
                with x_norm = 'X'
                with dd_bukrs-low = so_bukrs-low                "#EC *
                and return.
       DELETE it_pos WHERE u_xreversal <> ' '.
        clear : it_pos[], it_pos .
        import it_pos from memory id 'zit_pos'.
        free memory id 'zit_pos'.
        delete it_pos where blart <> 'DZ'.
        sort it_pos by belnr.
       APPEND LINES OF it_pos TO it_pos1.
       DELETE ADJACENT DUPLICATES FROM it_pos COMPARING belnr." commented by sarang
        clear : it_cust[], it_cust.
        if not it_pos[] is initial.
          select belnr wrbtr xref1 kunnr bschl 
          into corresponding fields of table it_cust
          from bseg
          for all entries in it_pos
          where belnr = it_pos-belnr
          and bukrs = it_pos-bukrs
          and gjahr = it_pos-gjahr
          and bschl in ('15','40') . 
         it_cust2[] = it_cust[].
          delete it_cust where bschl ne 15.
          delete it_cust2 where bschl ne 40.
          sort it_pos by konto.
        else.
          write : 20 '**No Transaction to Display**'.
        endif.
       DELETE it_pos WHERE u_xreversal = 'X'.
        tables bkpf.
        loop at it_pos.
          select single  * from bkpf where belnr = it_pos-belnr and bukrs = it_pos-bukrs and gjahr = it_pos-gjahr and xreversal = ' '.
          if sy-subrc = 0.
            append it_pos to it_pos_bc1.
          endif.
        endloop.
        clear it_pos.
        it_pos[] = it_pos_bc1[].
        sort it_pos by konto belnr xref3.
        loop at it_pos.
          read table it_cust2 with key belnr = it_pos-belnr.
          on change of it_pos-konto or "IT_CUST2-xref1 or
          it_pos-belnr.
            it_pos_bc[] = it_pos[].
            delete it_pos_bc[] where konto ne it_pos-konto.
            delete it_pos_bc[] where belnr ne it_pos-belnr.
            loop at it_pos_bc.
              sum.
              exit.
            endloop.
            append it_pos_bc to it_pos_nc.
          endon.
        endloop.
        free it_pos.
        it_pos[] = it_pos_nc[].
        data : w_amt1 type bseg-dmbtr,
              w_amt2 type bseg-dmbtr.
        clear : w_amt1 , w_amt2.
        sort it_pos by budat belnr konto.
        data : w_ch(5) type c,
               w_i type i.
        w_i = 0.
        loop at it_pos where shkzg = 'H' .
          clear w_text.
          w_i = w_i + 1 .
          w_ch = w_i.
          read table it_cust with key belnr = it_pos-belnr  kunnr = it_pos-konto.
          read table it_kna1 with key kunnr = it_pos-konto .
         CONCATENATE it_kna1-name1 INTO w_text.
          w_text = it_kna1-name1.
         CONDENSE w_text NO-GAPS.
          write : / w_ch left-justified  , 07 it_pos-budat ,20 it_pos-belnr(10) ,31 it_pos-konto(10),42 w_text(60).
          read table it_cust2 with key belnr = it_pos-belnr.
          if it_cust2-xref1 = 'Cash Payment' or it_cust2-xref1 = 'Cash'.
            if it_pos-dmshb < 0 .
             it_pos-dmshb = it_pos-dmshb * -1 .
              it_pos-dmshb = it_cust2-wrbtr.
            else.                              "+PM28072006
             it_pos-dmshb = it_pos-dmshb * -1 . "+PM28072006
              it_pos-dmshb = it_cust2-wrbtr.
            endif.
            write : 72 it_pos-dmshb.
            w_amt1 = w_amt1 + it_pos-dmshb.
          else.
            if it_pos-dmshb < 0 .
             it_pos-dmshb = it_pos-dmshb * -1 .
               it_pos-dmshb = it_cust2-wrbtr.
            else.                            "+PM28072006
             it_pos-dmshb = it_pos-dmshb * -1."+PM28072006
              it_pos-dmshb = it_cust2-wrbtr.
            endif.
            write : 87  it_pos-dmshb.
            w_amt2 = w_amt2 + it_pos-dmshb.
          endif .
        endloop .
      else.
        write : 20 '**No Transaction to Display**'.
      endif.
      clear : it_cust1[] ,w_pos .
      it_cust1[] = it_cust[] .
      sort it_cust1 by wrbtr.
      delete it_cust1 where xref1 <> 'Cash Payment' .
      delete it_cust1 where xref1 <> 'Cash' .
      loop at it_cust1.
        sum .
        w_pos = it_cust1-wrbtr .
        exit .
      endloop .
      clear :it_cust1[],w_neg .
      it_cust1[] = it_cust[] .
      sort it_cust1 by wrbtr.
      delete it_cust1 where xref1 = 'Cash Payment' .
      delete it_cust1 where xref1 = 'Cash' .
      loop at it_cust1.
        sum .
        w_neg = it_cust1-wrbtr .
        exit .
      endloop .
      if w_pos < 0.
        w_pos = w_pos * -1 .
      else.                 "+PM28072006
        w_pos = w_pos * -1. "+PM28072006
      endif.
      if w_neg < 0.
        w_neg = w_neg * -1 .
      else.                 "+PM28072006
        w_neg = w_neg * -1. "+PM28072006
      endif.
      write sy-uline(125) .
      write : /20 'Total Collection Amount -
    >'.
      write : 76 w_amt1 ,91 w_amt2.
      w_sub_tot = w_amt1 + w_amt2.
      if w_sub_tot < 0.
        w_sub_tot = w_sub_tot * -1.
      endif.
      write : 106 w_sub_tot.
      if pr_1 = 'X'.
        w_total_co = w_total_bf + w_sub_tot.
        if w_total_co < 0.
          w_total_co = w_total_co * -1.
        endif.
        write : /20 'Progressive Total C/O -
    >'.
        write : 106 w_total_co.
      endif.
      write sy-uline(125) .
    endform.                    "f002_item_data
         ENDIF .
    *END-OF-SELECTION.
          E N D       O F   S E L E C T I O N                           *
          At line selection                                             *
    *AT LINE-SELECTION.
          User Command Processing                                       *
    *AT USER-COMMAND.
          Top Of Page                                                   *
    top-of-page.
      select single * from t001 where bukrs = so_bukrs-low .
      select single * from adrc where addrnumber = t001-adrnr . "EC *
      write : /05  t001-butxt.
    CONCATENATE adrc-house_num1 '-' adrc-street INTO w_text1.
    CONCATENATE adrc-city1 '-' adrc-post_code1 INTO w_text2.
    WRITE : /05  w_text1 .
    WRITE : /05  w_text2 .
      write : /05  'Sales Organisation:', so_kunrg-low.
      write : /05  'Sales Office:', so_vkbur-low.
      skip 1.
      if pr_3 = 'X'.
        write : /05 'Agent Circulation Collection Statement From ' , so_fkdat-low , ' to ' ,so_fkdat-high .
      else.
        write : /05 'Advertisement  Collection Statement From ' , so_fkdat-low , ' to ' ,so_fkdat-high .
      endif.
      if pr_3 = 'X'.
        write  :/ sy-uline(125) .
        write :/07 'Date' ,20 'Doc No',31 'Code' ,42 'Agent Name & Place',84 'BY CASH' ,97 'BY CHQ/DD' ,115 'Prog. Total'.
        write  :/ sy-uline(125) .
      else.
       write  :/ sy-uline(125) .
       write :/07 'Date' ,20 'Doc No',31 'Code' ,42 'Advertisers Name' ,  84 'BY CASH' ,97 'BY CHQ/DD' ,115 'Prog. Total'.
       write  :/ sy-uline(125) .
      endif .
          End Of Page                                                   *
    END-OF-PAGE.END-OF-PAGE.

    Hello Selvi
    There is no need to use two subroutine. Actually, this would be bad programming. Instead use a switch for your subroutine which determines whether the calculation should be done for the actual and the previous day, e.g.:
    PERFORM do_calculation
                                     USING 'X'          " 'X' = calculate for previous day as well
                                     USING p_date   " current date
                              CHANGING gt_list.   " itab with list data
    And that's how the subroutine could look like:
    FORM do_calculation
                             USING VALUE(ud_calculate_previous_day)  TYPE c
                                        VALUE(ud_date)                             TYPE d
                      CHANGING ct_list    TYPE <table type>.
    * define local data
      DATA:
         ld_date_prev  TYPE d,
         lt_list_prev     TYPE <table type>.  " list for previous day
    * Do the calculations for the current day
      IF ( ud_calculate_previous_day = 'X' ).
        ld_date_prev = ud_date - 1.
        PERFORM do_calculation
                                         USING ' '  " ' ' = no calculation for previous day
                                                    ld_date_prev
                                  CHANGING lt_list_prev.   " itab with list data
      ENDIF.
    * Post-processing after calculation for both days
    ENDFORM.
    Regards
      Uwe

  • Vision Builder 7.0(IMAQ) : Using fxs in subVIs with references to image control

    When using IMAQ fxs (such as 'Write File') in subVIs, if one wanted to use references to an image control, what property or method would be used to feed into the image terminal in the imaq fx on the subVI? Is this possible?
    What did work: I was able to directly use the image control on the main feeding an image control on the subvi panel (which is then fed directly to imaq fx)
    What did not work: From a refnum control for the image on the main, I used (within the subVI) the value property fed to a 'Variant to Data' with type as image control, then feeding the output of this into imaq fx.

    Typically you would update an Image Display control from a subVI using the Value property nodes. However, this method does not currently work with LabVIEW 7 and Vision 7, but the issue will be resolved in the next release of LabVIEW and Vision.
    In the meantime, in addition to the solution you found you could also use a global variable to pass images from one VI to another. Using a global variable works, but not in the same way as a reference or property node would. With a reference or property node, you can pass a reference of the control to a subVI and have the subVI update the control's image. Using global variables, the subVI will update the global variable with the new images, but you need a loop monitoring the global variable in your top level VI.
    I hope this
    helps! Best wishes.
    Regards,
    Dawna P.
    Applications Engineer
    National Instruments

Maybe you are looking for

  • CS3 - What Are the Best Export Settings for Animation?

    I have edited a project in Premiere Pro CS3. It is animated, and I want to preserve as much of the quality of the animation as I can. What are the best possible settings that I can use to export the video to a .MOV file? A little background info, in

  • How do I get Adobe Reader to stop trying to open the game Diversion and find a better "opener"?

    I downloaded the game Diversion at least 4 times but I couldn't find it.  When I finally did, it turned out that Adobe Reader was trying to open it.  How do I fix this with the right "tool" for the job?

  • Reg: Workflow for Overall Purchase Requisition Release

    Hi Experts, I have got a requirement in Overall or Header level PR release. My question is, for Header Level release, I am using BUS2105 and what are the event I need to maintain, so that my workflow get trigger. Regards, Shriraam

  • COM ports configuration

    I need to connect a PDA Fijitsu Siemens Pocket Loox to the PC using the Bluetooth. I have successfully installed software for the dongle on the PC side BUT there is a problem to connect PDA to the PC using Bluettoth Serial Port. PDA Bluetooth softwar

  • Computer randomly locks up when firewire drives are connected?

    Here's what I have: - 2011 27" iMac i7 - 2011 15" MacBook Pro i7 I recently replaced all of my USB hard drives with Firewire drives, mostly as a speed and simplification measure. Under USB, I had to have a series of hubs which seemed to slow things d