Getting totals in a CFC
I am trying to use two SQL calls and set a couple variables
to gather the
balance of projects left for a member.
I first find out how many projects they have total for their
account.
(available)
Then I use the recordcount to find out how many projects they
current have
active. (used)
Then I subtract the active projects from the total and get
the
'projectsleft'
What did I do wrong in this component and how can I output
the final number
(projectsleft)
I want to create a component on another page and use the
'projectsleft'.
<cfcomponent>
<cffunction name="Balance" access="remote"
returntype="numeric">
<cfquery name="UsedProjects"
datasource="#Request.MainDSN#">
Select title
FROM projects
Where dirname = '#SESSION.MM_username#'
</cfquery>
<cfset used = #UsedProjects.RecordSet#>
<cfquery name="AvailProjects"
datasource="#Request.MainDSN#">
Select projects
FROM Members
Where username = '#SESSION.MM_username#'
</cfquery>
<cfset available = #AvailProjects.project#>
<cfset projectsleft = available - used>
<cfreturn projectsleft>
</cffunction>
</cfcomponent>
Thanks!
Wally Kolcz
Developer / Support
I appreciate your submission to my question, but I am asking
cause I don't
know. I apologize for my lack of knowledge. If I knew how to
do it
efficiently I would not be asking.
Also, I know the item is wrong. That is why I am asking how
make it right.
"Dan Bracuk" <[email protected]> wrote in
message
news:e9o4fe$aqf$[email protected]..
> What did you do wrong? This
> <cfset used = #UsedProjects.RecordSet#>
> does not give a recordcount.
>
> and this
> <cfset available = #AvailProjects.project#>
> does not give you a number.
>
> Plus if I remember correctly, cfc's do not recognize
session variables.
>
> That's the stuff that is definitely wrong. You are also
being
> inefficient.
> You should be able to get the answer in one query.
>
Similar Messages
-
Not able to get group name by using memberof class, getting Total groups as 0 even I am member of that group. Through this memberof class I am trying to find full qualified name(DN) of my group.
code I have used:
//specify the LDAP search filter
String searchFilter = "(&(objectClass=user)(CN=Username))";
//Specify the Base for the search
String searchBase = "";
Also I have used,
String searchFilter = "(&(objectClass=user)(CN=Username))";
//Specify the Base for the search
String searchBase = "ou=ibmgroups,o=ibm.com";
But in both cases I am getting value for Total groups as 0.
Code Reference:
* memberof.java
* December 2004
* Sample JNDI application to determine what groups a user belongs to
import java.util.Hashtable;
import javax.naming.*;
import javax.naming.ldap.*;
import javax.naming.directory.*;
public class memberof {
public static void main (String[] args) {
Hashtable env = new Hashtable();
String adminName = "CN=Administrator,CN=Users,DC=ANTIPODES,DC=COM";
String adminPassword = "XXXXXXX";
String ldapURL = "ldap://mydc.antipodes.com:389";
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
//set security credentials, note using simple cleartext authentication
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,adminName);
env.put(Context.SECURITY_CREDENTIALS,adminPassword);
//connect to my domain controller
env.put(Context.PROVIDER_URL,ldapURL);
try {
//Create the initial directory context
LdapContext ctx = new InitialLdapContext(env,null);
//Create the search controls
SearchControls searchCtls = new SearchControls();
//Specify the search scope
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
//specify the LDAP search filter
String searchFilter = "(&(objectClass=user)(CN=Andrew Anderson))";
//Specify the Base for the search
String searchBase = "DC=antipodes,DC=com";
//initialize counter to total the group members
int totalResults = 0;
//Specify the attributes to return
String returnedAtts[]={"memberOf"};
searchCtls.setReturningAttributes(returnedAtts);
//Search for objects using the filter
NamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);
//Loop through the search results
while (answer.hasMoreElements()) {
SearchResult sr = (SearchResult)answer.next();
System.out.println(">>>" + sr.getName());
//Print out the groups
Attributes attrs = sr.getAttributes();
if (attrs != null) {
try {
for (NamingEnumeration ae = attrs.getAll();ae.hasMore();) {
Attribute attr = (Attribute)ae.next();
System.out.println("Attribute: " + attr.getID());
for (NamingEnumeration e = attr.getAll();e.hasMore();totalResults++) {
System.out.println(" " + totalResults + ". " + e.next());
catch (NamingException e) {
System.err.println("Problem listing membership: " + e);
System.out.println("Total groups: " + totalResults);
ctx.close();
catch (NamingException e) {
System.err.println("Problem searching directory: " + e);
Any help will be highly appreciated.Not able to get group name by using memberof class, getting Total groups as 0 even I am member of that group. Through this memberof class I am trying to find full qualified name(DN) of my group.
code I have used:
//specify the LDAP search filter
String searchFilter = "(&(objectClass=user)(CN=Username))";
//Specify the Base for the search
String searchBase = "";
Also I have used,
String searchFilter = "(&(objectClass=user)(CN=Username))";
//Specify the Base for the search
String searchBase = "ou=ibmgroups,o=ibm.com";
But in both cases I am getting value for Total groups as 0.
Code Reference:
* memberof.java
* December 2004
* Sample JNDI application to determine what groups a user belongs to
import java.util.Hashtable;
import javax.naming.*;
import javax.naming.ldap.*;
import javax.naming.directory.*;
public class memberof {
public static void main (String[] args) {
Hashtable env = new Hashtable();
String adminName = "CN=Administrator,CN=Users,DC=ANTIPODES,DC=COM";
String adminPassword = "XXXXXXX";
String ldapURL = "ldap://mydc.antipodes.com:389";
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
//set security credentials, note using simple cleartext authentication
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,adminName);
env.put(Context.SECURITY_CREDENTIALS,adminPassword);
//connect to my domain controller
env.put(Context.PROVIDER_URL,ldapURL);
try {
//Create the initial directory context
LdapContext ctx = new InitialLdapContext(env,null);
//Create the search controls
SearchControls searchCtls = new SearchControls();
//Specify the search scope
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
//specify the LDAP search filter
String searchFilter = "(&(objectClass=user)(CN=Andrew Anderson))";
//Specify the Base for the search
String searchBase = "DC=antipodes,DC=com";
//initialize counter to total the group members
int totalResults = 0;
//Specify the attributes to return
String returnedAtts[]={"memberOf"};
searchCtls.setReturningAttributes(returnedAtts);
//Search for objects using the filter
NamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);
//Loop through the search results
while (answer.hasMoreElements()) {
SearchResult sr = (SearchResult)answer.next();
System.out.println(">>>" + sr.getName());
//Print out the groups
Attributes attrs = sr.getAttributes();
if (attrs != null) {
try {
for (NamingEnumeration ae = attrs.getAll();ae.hasMore();) {
Attribute attr = (Attribute)ae.next();
System.out.println("Attribute: " + attr.getID());
for (NamingEnumeration e = attr.getAll();e.hasMore();totalResults++) {
System.out.println(" " + totalResults + ". " + e.next());
catch (NamingException e) {
System.err.println("Problem listing membership: " + e);
System.out.println("Total groups: " + totalResults);
ctx.close();
catch (NamingException e) {
System.err.println("Problem searching directory: " + e);
Any help will be highly appreciated. -
How to get total in ALV report in same Internal table?
Data : Begin of it_data,
kunnr type kunnr,
name1 type name1,
amt1 type btrt01, " CURR 15,2
end of it_data.
loop at it_data into wa_data
endloop.
Hello friends,
I am developing one ALV report with 20 rows.
I have filled one internal table with some fileds like amount.
I want to get total of all amount1 in AMT1 field.
So, How to get total of amount in same internal table in ALV report ?
It is ok if i get duplicate rows in internal table.
Points 'll be awarded soon.
Regards,
NVMHi Ronny,
the alv output will display the sum at the last row.
for this functionality u have do this logic.
data: lw_fcat type slis_fieldcat_alv.
data: lt_fcat type slis_t_fieldcat_alv/
wa_fcat-fieldname = 'AMT1'.
wa_fcat-tabname = 'ITAB'.
wa_fcat-do_sum = 'X'.
append wa_fcat to lt_fcat.
and then pass it to reuse_alv_grid_display function,
regards,
Santosh Thorat -
Data : Begin of it_data,
kunnr type kunnr,
name1 type name1,
amt1 type btrt01, " CURR 15,2
end of it_data.
loop at it_data into wa_data
endloop.
Hello friends,
I am developing one ALV report with 20 rows.
I have filled one internal table with some fileds like amount.
I want to get total of all amount1 in AMT1 field.
So, How to get total of amount in same internal table in ALV report ?
It is ok if i get duplicate rows in internal table.
note : i need not data in field catlog
Points 'll be awarded soon.
Regards,Hai,
While Defining Field Catalog,Specify do_sum = 'X' for the field which you want the Total.Before that u have to sort that Values.
JUST CHECK THIS SAMPLE PROG
TABLES : STKO,STPO,MAKT,MAST.
TYPE-POOLS : SLIS.
DATA : BEGIN OF ISTKO OCCURS 0,
STLNR LIKE STKO-STLNR,
DATUV LIKE STKO-DATUV,
MATNR LIKE MAST-MATNR,
BMENG LIKE STKO-BMENG,
BMEIN LIKE STKO-BMEIN,
END OF ISTKO.
DATA : BEGIN OF ISTPO OCCURS 0,
STLNR LIKE STPO-STLNR,
IDNRK LIKE STPO-IDNRK,
MENGE LIKE STPO-MENGE,
MEINS LIKE STPO-MEINS,
MAKTX LIKE MAKT-MAKTX,
END OF ISTPO.
DATA : BEGIN OF IMAKT OCCURS 0,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
END OF IMAKT.
DATA : BEGIN OF IMAST OCCURS 0,
MATNR LIKE MAST-MATNR,
STLNR LIKE MAST-STLNR,
END OF IMAST.
DATA : IFIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WFIELDCAT TYPE SLIS_FIELDCAT_ALV,
ILAYOUT TYPE SLIS_LAYOUT_ALV,
IKEYINFO TYPE SLIS_KEYINFO_ALV,
IEVENT TYPE SLIS_T_EVENT,
WEVENT TYPE SLIS_ALV_EVENT,
ISORT TYPE SLIS_T_SORTINFO_ALV,
WSORT TYPE SLIS_SORTINFO_ALV.
PARAMETERS : P_NUM TYPE I DEFAULT 10.
START-OF-SELECTION.
PERFORM GETDATA.
PERFORM GETHEADERMAT.
PERFORM GET_MAT_DESC.
PERFORM BUILD_FCAT_HEAD.
PERFORM BUILD_FCAT_ITEM.
PERFORM BUILD_KEYINFO.
PERFORM BUILD_EVENT_TAB.
PERFORM BUILD_SORT_TAB.
PERFORM BUILD_LAYOUT.
PERFORM DISPLAY_DATA.
*& Form GETDATA
text
--> p1 text
<-- p2 text
FORM GETDATA .
SELECT STLNR DATUV BMENG BMEIN INTO CORRESPONDING FIELDS OF TABLE ISTKO
FROM STKO UP TO P_NUM ROWS.
IF NOT ISTKO[] IS INITIAL.
SELECT STLNR IDNRK MENGE MEINS INTO TABLE ISTPO FROM STPO FOR ALL ENTRIES IN ISTKO
WHERE STLNR = ISTKO-STLNR AND POSTP = 'L'.
ENDIF.
ENDFORM. " GETDATA
*& Form BUILD_FCAT_HEAD
text
--> p1 text
<-- p2 text
FORM BUILD_FCAT_HEAD .
WFIELDCAT-TABNAME = 'ISTKO'.
WFIELDCAT-FIELDNAME = 'STLNR'.
WFIELDCAT-SELTEXT_L = 'BOM no'.
WFIELDCAT-OUTPUTLEN = 15.
APPEND WFIELDCAT TO IFIELDCAT.
CLEAR WFIELDCAT.
WFIELDCAT-TABNAME = 'ISTKO'.
WFIELDCAT-FIELDNAME = 'DATUV'.
WFIELDCAT-SELTEXT_L = 'BOM date'.
WFIELDCAT-OUTPUTLEN = 15.
APPEND WFIELDCAT TO IFIELDCAT.
CLEAR WFIELDCAT.
WFIELDCAT-TABNAME = 'ISTKO'.
WFIELDCAT-FIELDNAME = 'MATNR'.
WFIELDCAT-SELTEXT_L = 'Header mat no'.
WFIELDCAT-OUTPUTLEN = 18.
APPEND WFIELDCAT TO IFIELDCAT.
CLEAR WFIELDCAT.
WFIELDCAT-TABNAME = 'ISTKO'.
WFIELDCAT-FIELDNAME = 'BMENG'.
WFIELDCAT-SELTEXT_L = 'Base qty'.
WFIELDCAT-OUTPUTLEN = 15.
APPEND WFIELDCAT TO IFIELDCAT.
CLEAR WFIELDCAT.
WFIELDCAT-TABNAME = 'ISTKO'.
WFIELDCAT-FIELDNAME = 'BMEIN'.
WFIELDCAT-SELTEXT_L = 'UOM'.
WFIELDCAT-OUTPUTLEN = 3.
APPEND WFIELDCAT TO IFIELDCAT.
CLEAR WFIELDCAT.
ENDFORM. " BUILD_FCAT_HEAD
*& Form BUILD_FCAT_ITEM
text
--> p1 text
<-- p2 text
FORM BUILD_FCAT_ITEM .
WFIELDCAT-TABNAME = 'ISTPO'.
WFIELDCAT-FIELDNAME = 'STLNR'.
WFIELDCAT-SELTEXT_L = 'BOM no'.
WFIELDCAT-NO_OUT = 'X'.
*WFIELDCAT-HOTSPOT = 'X'.
WFIELDCAT-OUTPUTLEN = 10.
APPEND WFIELDCAT TO IFIELDCAT.
CLEAR WFIELDCAT.
WFIELDCAT-TABNAME = 'ISTPO'.
WFIELDCAT-FIELDNAME = 'IDNRK'.
WFIELDCAT-SELTEXT_L = 'Material no'.
*WFIELDCAT-HOTSPOT = 'X'.
WFIELDCAT-OUTPUTLEN = 18.
APPEND WFIELDCAT TO IFIELDCAT.
CLEAR WFIELDCAT.
WFIELDCAT-TABNAME = 'ISTPO'.
WFIELDCAT-FIELDNAME = 'MAKTX'.
WFIELDCAT-SELTEXT_L = 'Material desc'.
WFIELDCAT-JUST = 'C'.
WFIELDCAT-OUTPUTLEN = 30.
APPEND WFIELDCAT TO IFIELDCAT.
CLEAR WFIELDCAT.
WFIELDCAT-TABNAME = 'ISTPO'.
WFIELDCAT-FIELDNAME = 'MENGE'.
WFIELDCAT-SELTEXT_L = 'Item qty'.
WFIELDCAT-OUTPUTLEN = 15.
WFIELDCAT-DO_SUM = 'X'.
APPEND WFIELDCAT TO IFIELDCAT.
CLEAR WFIELDCAT.
WFIELDCAT-TABNAME = 'ISTPO'.
WFIELDCAT-FIELDNAME = 'MEINS'.
WFIELDCAT-SELTEXT_L = 'UOM'.
WFIELDCAT-OUTPUTLEN = 3.
APPEND WFIELDCAT TO IFIELDCAT.
CLEAR WFIELDCAT.
ENDFORM. " BUILD_FCAT_ITEM
*& Form BUILD_KEYINFO
text
--> p1 text
<-- p2 text
FORM BUILD_KEYINFO .
IKEYINFO-HEADER01 = 'STLNR'.
IKEYINFO-ITEM01 = 'STLNR'.
ENDFORM. " BUILD_KEYINFO
*& Form DISPLAY_DATA
text
--> p1 text
<-- p2 text
FORM DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COM'
IS_LAYOUT = ILAYOUT
IT_FIELDCAT = IFIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = ISORT
IT_FILTER =
IS_SEL_HIDE =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = IEVENT[]
IT_EVENT_EXIT =
I_TABNAME_HEADER = 'ISTKO'
I_TABNAME_ITEM = 'ISTPO'
I_STRUCTURE_NAME_HEADER =
I_STRUCTURE_NAME_ITEM =
IS_KEYINFO = IKEYINFO
IS_PRINT =
IS_REPREP_ID =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB_HEADER = ISTKO
T_OUTTAB_ITEM = ISTPO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_DATA
*& Form GET_MAT_DESC
text
--> p1 text
<-- p2 text
FORM GET_MAT_DESC .
IF NOT ISTPO[] IS INITIAL.
SELECT MATNR MAKTX INTO TABLE IMAKT FROM MAKT FOR ALL ENTRIES IN ISTPO
WHERE MATNR = ISTPO-IDNRK.
ENDIF.
LOOP AT ISTPO.
READ TABLE IMAKT WITH KEY MATNR = ISTPO-IDNRK.
IF SY-SUBRC = 0.
ISTPO-MAKTX = IMAKT-MAKTX.
ENDIF.
MODIFY ISTPO.
ENDLOOP.
ENDFORM. " GET_MAT_DESC
*& Form BUILD_LAYOUT
text
--> p1 text
<-- p2 text
FORM BUILD_LAYOUT .
ILAYOUT-ZEBRA = 'X'.
ILAYOUT-COLWIDTH_OPTIMIZE = 'X'.
ENDFORM. " BUILD_LAYOUT
*FORM USER_COM USING PUCOM LIKE SY-UCOMM PSELFIELD TYPE SLIS_SELFIELD.
*CASE PUCOM.
*WHEN '&IC1'.
SET PARAMETER ID 'MAT' FIELD PSELFIELD-VALUE.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
*ENDCASE.
*ENDFORM.
*& Form BUILD_EVENT_TAB
text
--> p1 text
<-- p2 text
FORM BUILD_EVENT_TAB .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = IEVENT
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE IEVENT INTO WEVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC = 0.
WEVENT-FORM = 'TOPOFPAGE'.
MODIFY IEVENT FROM WEVENT INDEX SY-TABIX.
ENDIF.
ENDFORM. " BUILD_EVENT_TAB
*& Form TOPOFPAGE
text
FORM TOPOFPAGE.
DATA : ILISTHEAD TYPE SLIS_T_LISTHEADER,
WLISTHEAD TYPE SLIS_LISTHEADER.
WLISTHEAD-INFO = 'Its a test hierarchical sequential alv dispaly'.
WLISTHEAD-TYP = 'H'.
APPEND WLISTHEAD TO ILISTHEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = ILISTHEAD
I_LOGO = ''
I_END_OF_LIST_GRID =
ENDFORM.
*& Form GETHEADERMAT
text
--> p1 text
<-- p2 text
FORM GETHEADERMAT .
IF NOT ISTKO[] IS INITIAL.
SELECT MATNR STLNR INTO TABLE IMAST FROM MAST FOR ALL ENTRIES IN ISTKO
WHERE STLNR = ISTKO-STLNR.
ENDIF.
LOOP AT ISTKO.
READ TABLE IMAST WITH KEY STLNR = ISTKO-STLNR.
IF SY-SUBRC = 0.
ISTKO-MATNR = IMAST-MATNR.
ENDIF.
MODIFY ISTKO.
ENDLOOP.
ENDFORM. " GETHEADERMAT
*& Form BUILD_SORT_TAB
text
--> p1 text
<-- p2 text
FORM BUILD_SORT_TAB .
WSORT-FIELDNAME = 'STLNR'.
WSORT-TABNAME = 'ISTPO'.
WSORT-UP = 'X'.
WSORT-SUBTOT = 'X'.
WSORT-GROUP = 'UL'.
APPEND WSORT TO ISORT.
ENDFORM. " BUILD_SORT_TAB -
How to get total no. of threads in JVM?
I am trying to monitor the thread activity to detect any thread-leak in our system. Is there a way to get total number of threads so far being created in the JVM?
Thanks in advance.
- DavidThanks for the suggestion of getParent(). I actually found that the "activeCount()" method always returm me a number larger than I expect. I have to enumerate the thread group to get an array of Thread objects and count the array one by one. Then I will get the correct number of threads as I expected.
Don't know exactly the meaning of "active" threads.
- David -
How to get total number of nodes in a JTree?
Hi,
I am trying to get total number of nodes in a JTree, and cannot find a way to do it.
The current getRowCount() method returns the number of rows that are currently being displayed.
Is there a way to do this or I am missing something?
thanks,How many nodes does this tree have?
import java.awt.EventQueue;
import javax.swing.*;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.*;
public class BigTree {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
TreeModel model = new TreeModel() {
private String node = "Node!";
@Override
public void valueForPathChanged(TreePath path,
Object newValue) {
// not mutable
@Override
public void removeTreeModelListener(TreeModelListener l) {
// not mutable
@Override
public boolean isLeaf(Object node) {
return false;
@Override
public Object getRoot() {
return node;
@Override
public int getIndexOfChild(Object parent, Object child) {
return child == node ? 0 : -1;
@Override
public int getChildCount(Object parent) {
return 1;
@Override
public Object getChild(Object parent, int index) {
return node;
@Override
public void addTreeModelListener(TreeModelListener l) {
// not mutable
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.getContentPane().add(new JScrollPane(new JTree(model)));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}But for bounded tree model using DefaultMutableTreeNode look at bread/depth/preorder enumeration methods to walk the entire tree. Or look at the source code for those and adapt them to work with the TreeModel interface. -
How to get total number of days
Hi All,
how to get total number of days , for example if month eq 05 then need to get total number of days until MAY 31.
and how to get total number of days in a month.
Thank You,,
Sriii..Hi Sridhar,
Pls Try to search before posting general questions.
Try this,
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = p_lv_date1
i_datum_von = p_lv_date2
IMPORTING
e_tage = p_e_date_difference
EXCEPTIONS
days_method_not_defined = 1
OTHERS = 2
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Regards,
Sunil kairam. -
How to get total number of days in current Fiscal period/year
Hi,
I need to get total number of days in current Fiscal period/year (current month) and assign it to an infoobject. I need a routine for this. Is there any function module to get this.If possible pls paste the ABAP code also for this task. Thanks in advancehere is the FM:
LAST_DAY_IN_PERIOD_GET
KJ!!! -
How to get total number of result count for particular key on cluster
Hi-
My application requirement is client side require only limited number of data for 'Search Key' form total records found in cluster. Also i need 'total number of result count' for that key present on the custer.
To get subset of record i'm using IndexAwarefilter and returning only limited set each individual node. though i get total number of records present on the individual node, it is not possible to return this count to client form IndexAwarefilter (filter return only Binary set).
Is there anyway i can get this number (total result size) on client side without returning whole chunk of data?
Thanks in advance.
Prashantuser11100190 wrote:
Hi,
Thanks for suggesting a soultion, it works well.
But apart from the count (cardinality), the client also expects the actual results. In this case, it seems that the filter will be executed twice (once for counting, then once again for generating actual resultset)
Actually, we need to perform the paging. In order to achieve paging in efficient manner we need that filter returns only the PAGESIZE records and it also returns the total 'count' that meets the criteria.
If you want to do paging, you can use the LimitFilter class.
If you want to have paging AND total number of results, then at the moment you have to use two passes if you want to use out-of-the-box features because LimitFilter does not return the total number of results (which by the way may change between two page retrieval).
What we currently do is, the filter puts the total count in a static variable and but returns only the first N records. The aggregator then clubs these info into a single list and returns to the client. (The List returned by aggregator contains a special entry representing the count).
This is not really a good idea because if you have more than one user doing this operation then you will have problems storing more than one values in a single static variable and you used a cache service with a thread-pool (thread-count set to larger than one).
We assume that the aggregator will execute immediately after the filter on the same node, this way aggregator will always read the count set by the filter.
You can't assume this if you have multiple client threads doing the same kind of filtering operation and you have a thread-pool configured for the cache service.
Please tell us if our approach will always work, and whether it will be efficient as compared to using Count class which requires executing filter twice.
No it won't if you used a thread-pool. Also, it might happen that Coherence will execute the filtering and the aggregation from the same client thread multiple times on the same node if some partitions were newly moved to the node which already executed the filtering+aggregation once. I don't know anything which would even prevent this being executed on a separate thread concurrently.
The following solution may be working, but I can't fully recommend it as it may leak memory depending on how exactly the filtering and aggregation is implemented (if it is possible that a filtering pass is done but the corresponding aggregation is not executed on the node because of some partitions moved away).
At sending the cache.aggregate(Filter, EntryAggregator) call you should specify a unique key for each such filtering operation to both the filter and the aggregator.
On the storage node you should have a static HashMap.
The filter should do the following two steps while being synchronized on the HashMap.
1. Ensure that a ConcurrentLinkedQueue object exists in a HashMap keyed by that unique key, and
2. Enqueue the total number count you want to pass to the aggregator into that queue.
The parallel aggregator should do the following two steps while being synchronized on the HashMap.
1. Dequeue a single element from the queue, and return it as a partial total count.
2. If the queue is now empty, then remove it from the HashMap.
The parallel aggregator should return the popped number as a partial total count as part of the partial result.
The client side of the parallel aware aggregator should sum the total counts in the partial result.
Since the enqueueing and dequeueing may be interleaved from multiple threads, it may be possible that the partial total count returned in a result does not correspond to the data in the partial result, so you should not base anything on that assumption.
Once again, that approach may leak memory based on how Coherence is internally implemented, so I can't recommend this approach but it may work.
Another thought is that since returning entire cached values from an aggregation is more expensive than filtering (you have to deserialize and reserialize objects), you may still be better off by running a separate count and filter pass from the client, since for that you may not need to deserialize entries at all, so the cost on the server may be lower.
Best regards,
Robert -
HOW TO GET TOTAL BEFORE DISCOUNT AMOUNT IN MARKETING DOCUMNET
HI.
I need one requirement in this,
i need to capture the Total before discount amount at A/R invoice.
i checked in tables Discount and Discount amount will be come below Total before Discount amount
but Total Before Discount Amount i am not able to get it from the Database.
Any information plz Update me.Hi Srinivas,
As already answered by Seniors that you have to apply Formula to get Total before Discount. Please check below
Total Before Discount = ( DocTotal + DiscSum - VatSum )
If you want to put FMS then please try below FMS for Header Level
SELECT ( $[OINV.DocTotal] + $[OINV.DiscSum] - $[OINV.VatSum] )
Hope this helps
Regards::::
Atul Chakraborty -
How to get total of any field in sapscript?
Hello ,
i m making sapscript...
How to get total of any field in sapscript?Hi
Yes, you can define a variabe in your print program and pass it to the SAPScript.
LIKE:
Define L_SUM in the Global data.
DATA: L_SUM TYPE BSEG-DMBTR.
LOOP AT ITAB.
L_SUM = L_SUM + ITAB-AMOUNT.
ENDLOOP.
CALL FUNCTION 'WRITE_FORM'
WINDOW = 'MAIN'
ELEMENT = 'TOTAL'.
Now, in your SAPScript, create a text element in MAIN window
/E TOTAL
Total,, &L_SUM&.
Go through below link
http://sap-img.com/sapscripts/sapscript-how-to-calculate-totals-and-subtotals.htm
Regards,
Chandru -
Query to get total counts in the given scenario
Hi,
I am using Oracle 10g
I have a table A with following data
AgId Trm CD S
1000 100010 12-JAN A
1000 100019 20-MAR A
1000 100019 20-JUL D
1001 100011 25-JAN A
1001 100011 20-FEB D
1001 100011 23-MAR A
1001 100012 31-JAN A
1002 100013 14-FEB A
1002 100013 05-APR D
1002 100015 02-MAY A
1003 100014 03-MAR A
1003 100014 25-MAR D
1004 100016 22-MAY A
1004 100017 21-JUN A
1004 100018 01-JUL A
1005 100020 21-MAY D
1005 100020 21-JUL A
1005 100020 11-AUG D
Here the overall status of AgId '1000' is A as he is having atleast 1 Trm active
Similarly, status of AgId '1001' is A
status of AgId '1002' is A
But,status of AgId '1003' is D as his trm is disconnected after activation(according to date column'CD')
Then, status of AgId '1004' is A
and finally status of AgId '1005' is D again as his trm deactivated, activated and deactivated at last
So, considering these criteria can any one give me a query to get total no of AgId's who are 'Active' and similarly for 'Deactive'Hi,
when you put some code please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
CREATE TABLE ... etc.
{noformat}{noformat}
Also do not forget to put correct statements. Your insert were missing semicolon at the end.
Coming back to your problem, I assum that the current status of any trm is the latest status so I have done what follows:
{code:sql}
SELECT agid
, trm
, cd
, s
, ROW_NUMBER () OVER (PARTITION BY agid, trm ORDER BY cd) rn
, COUNT (*) OVER (PARTITION BY agid, trm) rn_tot
FROM a
ORDER BY agid, trm, cd;
Output:
AGID TRM CD S RN RN_TOT
1000 100010 12-JAN-12 A 1 1
1000 100019 20-MAR-12 A 1 2
1000 100019 20-JUL-12 D 2 2
1001 100011 25-JAN-12 A 1 3
1001 100011 20-FEB-12 D 2 3
1001 100011 23-MAR-12 A 3 3
1001 100012 31-JAN-12 A 1 1
1002 100013 14-FEB-12 A 1 2
1002 100013 05-APR-12 D 2 2
1002 100015 02-MAY-12 A 1 1
1003 100014 03-MAR-12 A 1 2
1003 100014 25-MAR-12 D 2 2
1004 100016 22-MAY-12 A 1 1
1004 100017 21-JUN-12 A 1 1
1004 100018 01-JUL-12 A 1 1
1005 100020 21-MAY-12 D 1 3
1005 100020 21-JUL-12 A 2 3
1005 100020 11-AUG-12 D 3 3I have used to columns rn and rn_tot to find the latest entry for a specific agid, trm
Using the query above I have done the following:
WITH mydata AS
SELECT agid
, trm
, cd
, s
, ROW_NUMBER () OVER (PARTITION BY agid, trm ORDER BY cd) rn
, COUNT (*) OVER (PARTITION BY agid, trm) rn_tot
FROM a
SELECT agid
, CASE WHEN SUM (CASE s WHEN 'A' THEN 1 END) > 0 THEN 'A' ELSE 'D' END s
FROM mydata
WHERE rn = rn_tot
GROUP BY agid;
Output:
AGID S
1000 A
1001 A
1002 A
1003 D
1004 A
1005 D
{code}
Which is listing the agid and its status if at least there is one trm with final status 'A' for that agid.
To sum up everything you can do simply like this:
{code:sql}
WITH mydata AS
SELECT agid
, trm
, cd
, s
, ROW_NUMBER () OVER (PARTITION BY agid, trm ORDER BY cd) rn
, COUNT (*) OVER (PARTITION BY agid, trm) rn_tot
FROM a
totdata AS
SELECT agid
, CASE WHEN SUM (CASE s WHEN 'A' THEN 1 END) > 0 THEN 'A' ELSE 'D' END s
FROM mydata
WHERE rn = rn_tot
GROUP BY agid
SELECT S, COUNT(*) cnt
FROM totdata
GROUP BY S;
Output:
S CNT
D 2
A 4
{code}
Regards.
Al -
Getting total number of instances (objects) running in a JVM
Hello,
Is there any way to get total number of objects in the heap of a JVM without using any profiling tools like JProbe
Regards,
Nikhil.K.RHave you looked at the JDK troubleshooting tools, in particular jmap -histo:
http://java.sun.com/javase/6/docs/technotes/tools/index.html#troubleshoot
You might also find useful info in the troubleshooting guide:
http://java.sun.com/javase/6/webnotes/trouble/index.html -
Hello Friends
How to get Total Amt in Figures in SAP B1 Sales Delivery & Tax Invoice report.
Thanks & Regards.Hi Mohammed
Check the Fig in words check box in the PLD properties window.
HTH
Thanks & Regards
baskar -
How to get total at each hierarchy
Hello Gurus,
Does anybody know how to get total at each level.
I mean, if I have the following structure...
Level 1
Level 2
Level 3
Level 4
Level 5
At level 5 we have the following calculation
Volume Price Amount(From Formula Volume * price)
5 2 10,00
6 3 12,00
7 4 28,00
My question is how to get a sum of (10,00 + 12,00 +28,00 = 50,00) at level 4?
Thanks in advance.
With regards,
AnandDoes anybody know how to get total at each level.
I mean, if I have the following structure...
Level 1
Level 2
Level 3
Level 4
Level 5
At level 5 we have the following calculation
Volume Price Amount(From Formula Volume * price)
5 2 10,00
6 3 12,00
7 4 28,00
I am getting following results : It is adding volume and price then multiplying volume * price and giving results.
18 9 18 * 9 = 162,00
But I have to get sum of ( 10,00 + 12,00 +28,00 = 50,00) at level 4.
My question is how to get a sum of (10,00 + 12,00 +28,00 = 50,00) at level 4?
Thanks.
With regards,
Anand
Maybe you are looking for
-
WBS wise Line Items in PO output
Hi, In a PO there are several line items and some have different account assignment for different WBS elements.The requirement is that the printout of the PO given to the vendor should have the sub-total for each WBS element and at the end the Total
-
The cooling fan is strangely noisy
Hi, I'm using dv6-6023tx laptop for 1 year. Its cooling fan was ok since when i purchased it, but it suddenly became so noisy with annoying spinning sounds from the last few days. I don't know why it happened. I didn't touch or change any hardware an
-
Is there a way to disable a CPU core to save battery on the Twist?
That thing overheats even when it's on low power (stepping on lowest). Can we disable a core to make it less hot?
-
I accidently added like 200 pictures files into my sidebar and i cant get rid of them! Is there some way to batch delete these from my sidebar? Even when i try to delete them individually, they keep reappearing as I'm trying to delete them. Help me!
-
Error in Database accessing!!!
Hello, i get this error when the application is running..... this i quite often Error Type : SQL FETECH Cursor error, couldn't do a physical order read to fetch next row. (ISAM error code: -107 DB_ER_INVALID STATE) Class :qqdb_usageException Error #