VPRs ctype issue

Dear MMians,
I am working on service contract - After sales service
while saving teh contract getting the following info as error
"Error in acc detrermintaion error""
on deep analysis we found that it is not picking the VPRS value and showing 0 price.
how to fix this
Pl notethat this is service matl and no accounting views r maintained
pl reply
guru

Hi Sachin,
For the similar issue you face, there has been a discussion in the forum.. Pls check
VPRS retrives the cost of the Material from the material master data > Accounting 1 tab to the Sales order.
Once the cost is found, then Profit margin  (Net value - cost) is calculated.
VPRS does not contain any Access sequence.
With the help of its Condition category "G", it accesses the Material master > Accounting tab 1 and takes cost.
There may be two cost specified in the Material master. They are
- Moving Avarage Price
- Standard Price
Which one system will consider that depends upon the "Price control" field.
If the value is "V' in the Price control field, the system takes the "Moving Avarage Price" and if it is "S", then system takes the "Standard Price".
So, you must ensure these few control
- VPRS should  NOT have any Access sequence.
- Condition category "G" must have been assigned to VPRS.
- VPRS must have been activated as "Statistical" condition in the Pricing Procedure and should not have any Account key.
With Regards
S.Siva

Similar Messages

  • Cx_Oracle and ctypes issue

    Hello,
    I have some code that works fine (using ctypes to call a dll), unless I run cx_Oracle first then I get an error:
    WindowsError: [Error 126] The specified module could not be found
    An example of the code is below:
    query = '''select * from table'''
    cx_Oracle.makedsn(host="host", port=1111, service_name='service.name')
    db_conn = cx_Oracle.connect('/@somewhere')
    cursor = db_conn.cursor()
    cursor.execute(query)
    db_conn.close()
    lib_path = os.path.join("C:\\Program Files (x86)\\app", "data.dll")
    self.externallib = ctypes.windll.LoadLibrary(lib_path)
    I am using python 2.7.5
    If I comment out the cx_Oracle code it works fine OR if I run it first.
    Any thoughts appreciated,
    Bevan

    Are you using Instant Client?  What version of IC or the Oracle client libraries are you using?
    Does data.dll have other dependencies?
    Is there a symbol clash between Oracle libs and data.dll - does the same problem occur when loading another DLL?

  • VPRS Cost vs Goods Issue Cost Mov. 653

    Hi experts,
    i have this problem:
    1) i make a Sales Order type credit note request using VA01 in reference to an invoice.
    2) the VRPS condition comes from the original invoice and that is ok.
    3) the system works with average cost
    4) when i do the goods issue posting in VL02N, the systems does a movement type 653 and the related FI document considers the cost from material  master record and it doesnt consider the VPRS cost from the credit note request.
    Example:
    Master Record has 120 USD as cost 'V' for 1000 PC
    VPRS in Credit Note Request is 100 USD 1000 PC
    FI document related to 653 movement considers 120 USD for 1000 PC
    I need that FI doc considers the VPRS cost. How can i do that?
    Thanks a lot,
    Alejo

    Looks like you are using Price control V - Moving Average cost in your material master. Try to use Price Control S and the VPRS will be stable in all the documents. T Code MM02 - Give your material - Costing 2 tab - Under Valudation data check the price control.
    Regards
    Sai

  • VPRS issue in STO - IC Billing process flow

    Hi Experts,
    I am working on following process flow (Stock transport PO - Delivery - Intercompany billing).
    Same condition type ZIXX is maintained in MM & SD Pricing procedure. In PO (STO), ZIXX is determined based on material valuation data and the same amount gets copied to IC billing.
    Along with ZIXX, we have VPRS condition type in billing pricing procedure. But issue is that: VPRS does not get determine. System analysis shows message 217 (error in quantity/ value determination for VPRS).
    Meanwhile, condition amount for ZIXX (determined in PO) and VPRS (determined in IC billing) may differ in some of the business scenarios. So both condition types are needed.
    Following settings have been maintained:
    ·         Copy control settings between delivery & IC billing document
    o   Price source A (Purchase order)
    o   Pricing type C (Copy manual pricing elements and redetermine others)
    ·         Item category (Intercompany) has marked for ‘Determine cost’ with billing relevance as A (delivery related billing)
    ·         Condition type VPRS
    o   marked as G (Internal Price)
    o   marked for ‘quantity conversion
    o   marked as ‘statistical’ in billing pricing PP
    o   subtotal B and requirement routine 4 (Cost)
    ·         Condition type ZIXX
    o   Marked as G (Internal price) in MM Pricing procedure
    o   Marked as H (Basic Price) in SD PP with requirement routine as 2 (item with pricing)
    ·         Material type is updated for ‘quantity and value update’ in SAP T.Code: OMS2
    Kindly let me know, how we can resolve VPRS issue.

    Hi Sachin,
    For the similar issue you face, there has been a discussion in the forum.. Pls check
    VPRS retrives the cost of the Material from the material master data > Accounting 1 tab to the Sales order.
    Once the cost is found, then Profit margin  (Net value - cost) is calculated.
    VPRS does not contain any Access sequence.
    With the help of its Condition category "G", it accesses the Material master > Accounting tab 1 and takes cost.
    There may be two cost specified in the Material master. They are
    - Moving Avarage Price
    - Standard Price
    Which one system will consider that depends upon the "Price control" field.
    If the value is "V' in the Price control field, the system takes the "Moving Avarage Price" and if it is "S", then system takes the "Standard Price".
    So, you must ensure these few control
    - VPRS should  NOT have any Access sequence.
    - Condition category "G" must have been assigned to VPRS.
    - VPRS must have been activated as "Statistical" condition in the Pricing Procedure and should not have any Account key.
    With Regards
    S.Siva

  • Cost(vprs) of free goods with batch managment

    Dear Gurus,
    I have a problem ahout free goods with batch management.
    Cost(VPRS) is not accumulated in billing(free goods is not relevant for billing).
    My configurations are shown as below:
    Ordered goods (and batch) item category :zta1(copied from tan)
    Free goods (and batch) item category :zann (copied from tann) pricing:B ;not relevant for billing;dermination cost:X
    copy control(from delivery to billing):
    ztan: accumulation cost :X
    If I use the material without batch management,Cost of free goods(without batch) is accumulated to main item(ordered goods).
    So, what can I do?
    Thanks and Best Regards,
    Lykin Kan

    Hi,
    These notes are useful:
    SAP Note 1365939 - VPRS logic and Customizing settings in SD
    SAP Note 547570 - FAQ: VPRS in pricing
    If you have the problem in the transfer from SD conditions to CO-PA, check if you transfer only invoices to COPA, if you don't invoice the deliveries of free goods, then you don't transfer this 'sales' or costs of 'gifts' to COPA. You can check the customizing of COPA in tcode ORKE (IMG for COPA). SAP Note 74486 - INFO: Overview of consulting notes for CO-PA is a good summary about this issue.
    I hope this helps you
    Regards,
    Eduardo
    PD: I forgot SAP Note Number 33968 SD/CO-PA: Characteristics from sales doc tables
    Edited by: E_Hinojosa on Sep 10, 2010 9:44 AM

  • Price condition equal to VPRS cost of goods

    I have a senario ,which we will create sales orders for customers with sales price equals to the MAP(moving average price) at the  time when the SO being input .And the sales price in sales orders should be copy to the billing whether  the MAP has changed or not .
    Now I have set up an pricing procedure ,which  use  VPRS  as the sales price condition type ,but here comes another question when I create billing according to the delivery . When I create the billing document ,the net value is defferent with the net value of the sales order ,because the MAP has changed during the goods issue.
    Is there any idea that can make sure the sale price equals to the MAP , and the billing net value is same as sales order net value?
    can you give me some advice ? thanks for you help!

    Hi,
    The pricing type (Copy control)  is an extremely important field. It is worthwhile keeping this entry
    in mind when creating your pricing condition types. As a rule of thumb, you should
    have all item categories for a particular sales document with the same settings.
    Generally, you may use pricing type B (carry out new pricing), G (copy pricing
    elements unchanged and redetermine taxes), or C (copy manual pricing elements
    and redetermine the others).
    When using condition B all manual pricing condition types are lost.
    If you want to copy the sales order to the invoice without changing the sales order
    conditions, use pricing rule G. This will copy the pricing conditions from the order into the
    invoice without changing them, but will redetermine the taxes.
    Regards...
    SBC

  • Free of Charge order: COGS (VPRS) is not transferred to CO-PA

    Dear SD gurus
    I have FOC order and I’d like to transfer its cost to CO-PA.
    Initially, only delivery process exist, but I noticed that without
    billing, data is not transferred to CO-PA.
    So, we added billing process with no accounting doc.
    But, condition type VPRS seems to be NOT transferred to CO-PA.
    Is there any solution?
    Yoshi

    Have a look at this document
    COGS not posted to costing based CO-PA during Goods Issue - ERP Financials - SCN Wiki
    G. Lakshmipathi

  • Filter Coding Issues

    I've been following (roughly) the simple virus scanner interface that SUN provides, and adapted it into a slightly heavier weight filter that interfaces with libclamav. At first both were compiled using GCC, and I thought due to some of the weird problems I had when debugging flags were inserted, maybe Sun Studio would give better results. It hasn't, and I'm at a bit of a loss as to what to do next.
    The symptom is that parts of the message just dissapear, and I see the old mime boundaries within the message body, so it seems like there's some pointer indicating where the message starts that's being corrupted by something in my code.
    Interestingly, if I stop processing the message while still inside the headers, there is no problem, but that's not a very effective virus scanner if it can only look at the content type and filename of the part now is it?
    This happens regardless of whether I use GCC or CC, and I'm using 0.88.1 of clamav. The output message is shown last. It should be fairly obvious what's wrong with it.
    Here's my code, perhaps someone can tell me what I'm doing wrong.
    ** WARNING ** This IS NOT polished code, so please don't expect it to be perfect. It's clean, but includes absolute pathnames, and some other nauties that should be removed before anyone even thinks of reusing this. Once it actually works, I'll do the nessisary code cleanup, and release this to the community to do whatever anyone wants with.
    Makefile
    SERVER_ROOT=/opt/SUNWmsgsr
    INSTALL_LOCATION=/var/opt/SUNWmsgsr/site-programs/
    INCLUDE=-I${SERVER_ROOT}/include
    LIBPATH=-L${SERVER_ROOT}/lib
    CLAMLIBS=`/usr/local/bin/clamav-config --libs` -lclamav
    CLAMFLAGS=`/usr/local/bin/clamav-config --cflags`
    LIBS=-lmtasdk ${CLAMLIBS}
    FLAGS=${CLAMFLAGS}
    all:
            cc ${FLAGS} -o msgsr_clamav msgsr_clamav.c \
                    ${INCLUDE} ${LIBPATH} ${LIBS}
    install:
            cp msgsr_clamav ${INSTALL_LOCATION}
            cp msgsr_clamav.cnf ${INSTALL_LOCATION}************************************************
    Expansions
    CLAMLIBS=-L/usr/local/lib -lz -lbz2 -lpthread -lclamav
    CLAMFLAGS=-I/usr/local/include -xO4************************************************
    msgsr_clamav.c
    * msgsr_clamav
    * Interface the Sun Java System Message Server with LibClamAV
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <ctype.h>
    #include <pthread.h>
    #include "clamav.h"     // LibClamAV Header
    #include "mtasdk.h"
    * A structure to store channel options
    typedef struct {
         /* Produce debug output? */
         int debug;
         // Maximum size (in bytes) attachment to scan
         int scan_maxsize;
         // Scan recursion level
         int scan_recursion_level;
         // Max files
         int scan_maxfiles;
         // Path to ClamAV Virus Database
         char db_dir[BIGALFA_SIZE+3];
         // Used Internally by ClamAV. Stored here for ease of access
         struct cl_node *root;
         unsigned int signo;
         struct cl_stat dbstat;
         pthread_mutex_t reload_mutex;
         // MIME types to ignore
         char ignore_mime_types[BIGALFA_SIZE+3];
         // Types of files to ignore
         char ignore_file_types[BIGALFA_SIZE+3];
         /* Unwanted MIME content types (ALWAYS stripped, never scanned) */
         char bad_mime_types[BIGALFA_SIZE+3];
         /* Unwanted file types (ALWAYS stripped, never scanned)*/
         char bad_file_types[BIGALFA_SIZE+3];
         /* Length of bmt string */
         size_t bmt_len;
         /* Length of bft string */
         size_t bft_len;
    } our_options_t;
    // A structure passed per message to contain message specific data, including open files, etc.
    typedef struct {
         // The filename of the temp file in use so it can be unlinked when we're done with it.
         char temp_file_name[BIGALFA_SIZE * 2 + 10];
         // The file * to the temp file in use, so we don't have to reopen it across calls to decode_inspect
         FILE *temp_file;
         // A pointer to the single instance of our_options_t that is shared across all threads
         our_options_t * options;
    } msg_temp_data_t;
    * Forward declarations
    static void error_exit(int ires, const char *msg);
    static void error_report(our_options_t *options, int ires, const char *func);
    static void error_reports(our_options_t *options, const char* errStr, const char *func);
    static int is_bad_mime_type(our_options_t *options, mta_decode_t *dctx, char *buf, size_t maxbuflen);
    static int is_bad_file_type(our_options_t *options, mta_opt_t *params, const char *param_name, char *buf, size_t maxbuflen);
    static int load_options(our_options_t *options);
    static mta_dq_process_message_t process_message;
    static mta_decode_read_t decode_read;
    static mta_decode_inspect_t decode_inspect;
    * main() -- Initialize the MTA SDK, load our options, and then
    * start the message processing loop.
    int main()
         int ires,ret;
         char error_msg[BIGALFA_SIZE+3];
         our_options_t options;
         * Initialize the MTA SDK
         * See explanatory comment 1
         if ((ires = mtaInit(0)))
              error_exit(ires, "Unable to initialize the MTA SDK");
         * Load our channel options
         * See explanatory comment 2
         if ((ires = load_options(&options)))
              error_exit(ires, "Unable to load our channel options");
         * Initialize the ClamAV Virus Engine and Database
         // Preconditions to initializing the ClamAV database
         options.root=NULL; options.signo=0;
         // Load the virus database
         mtaLog("cl_loaddbdir() loading database from %s",options.db_dir);
         if ((ret = cl_loaddbdir(options.db_dir, &options.root, &options.signo)))
              sprintf(error_msg,"cl_loaddbdir() error: %s", cl_strerror(ret));
              error_exit(MTA_NO,error_msg);
         mtaLog("cl_loaddbdir() loaded %d virus definitions",options.signo);
         // Internalize the virus database structure
         mtaLog("cl_build() initializing database");
         if((ret = cl_build(options.root)))
              sprintf(error_msg,"cl_build() error: %s", cl_strerror(ret));
              error_exit(MTA_NO,error_msg);
         // Keep track of database updates
         memset(&options.dbstat, 0, sizeof(struct cl_stat));
         cl_statinidir(options.db_dir, &options.dbstat);
         // Initialize our reload mutex
         if (ret = pthread_mutex_init(&options.reload_mutex,NULL))
              sprintf(error_msg,"pthread_mutex_init() error: %d", ret);
              error_exit(MTA_NO,error_msg);
         * Now process the queued messages. Be sure to indicate a
         * thread stack size sufficient to accomodate message
         * enqueue processing.
         * See explanatory comment 3
         if ((ires = mtaDequeueStart((void *)&options,
         process_message, NULL, 0)))
         error_exit(ires, "Error during dequeue processing");
         * All done
         cl_free(options.root);
         mtaDone();
         return(0);
    *Reloads the virus database and re-initializes the in memory structure
    * Loads a new virus database, then if all succeeds, it
    * swaps the new database with the old one.  It's assumed
    * clamav releases the database gracefully, but another mutex
    * may be required if this is not the case.
    static int reload_database(our_options_t *options)
         struct cl_node *newroot = NULL,*oldroot;
         char error_msg[BIGALFA_SIZE+3];
         int ret;
         unsigned int signo=0;
         if (pthread_mutex_trylock(&options->reload_mutex)) {     // Only one reload at a time thank you.
              if(cl_statchkdir(&options->dbstat) == 1) {     // Make sure we actually need an update
                   mtaLog("reload_database() Virus database is stale... reloading");
                   mtaLog("cl_loaddbdir() reloading database from %s",options->db_dir);
                   // Load the new virus database
                   if ((ret = cl_loaddbdir(options->db_dir, &newroot, &signo)))
                        mtaLog("cl_loaddbdir() error: %s", cl_strerror(ret));
                        return (-1);
                   mtaLog("cl_loaddbdir() loaded %d virus definitions",options->signo);
                   // Internalize the virus database structure
                   mtaLog("cl_build() re-initializing database");
                   if((ret = cl_build(newroot)))
                        mtaLog("cl_build() error: %s", cl_strerror(ret));
                        mtaLog("reload_database() Database reload aborted");
                        cl_free(newroot);
                        return (-2);
                   // Save a pointer to the old root
                   oldroot = options->root;
                   // Swap in the new root and signo
                   options->root = newroot;
                   options->signo = signo;
                   // Release the old root
                   cl_free(oldroot);
                   mtaLog("database_reload() Successfully loaded new virus database");
                   // Keep track of database updates
                   cl_statfree(&options->dbstat);
                   cl_statinidir(options->db_dir, &options->dbstat);
              pthread_mutex_unlock(&options->reload_mutex);
    * process_message() -- This routine is called by
    * mtaDequeueStart() to process each queued
    * message. We don&#31258; make use of ctx2, but
    * ctx1 is a pointer to our channel options.
    * See explanatory comment 4
    static int process_message(void **ctx2, void *ctx1, mta_dq_t *dq, const char *env_from, size_t env_from_len)
         const char *adr;
         int disp, ires;
         size_t len;
         mta_nq_t *nq;
         msg_temp_data_t msg_data;
         * Initializations
         nq = NULL;
         msg_data.options = (our_options_t *)ctx1;
         msg_data.temp_file = NULL;
         * Check the virus database to make sure it isn't stale
         * If it it's not currently reloading, and is stale, reload it.
         //if(cl_statchkdir(&(msg_data.options->dbstat)) == 1)
         //     reload_database(msg_data.options);
         * A little macro to do error checking on mta*() calls
         #define CHECK(f,x) \
         if ((ires = x)) { error_report(msg_data.options, ires, f); goto \
              done_bad; }
         * Start a message enqueue. Use the dequeue context to copy
         * envelope flags fromt the current message to this new
         * message being enqueued.
         * See explanatory comment 5
         CHECK("mtaEnqueueStart", mtaEnqueueStart(&nq, env_from, env_from_len, MTA_DQ_CONTEXT, dq, 0));
         * Process the envelope recipient list
         * See explanatory comment 6
         while (!(ires = mtaDequeueRecipientNext(dq, &adr, &len, 0)))
              * Add this envelope recipient address to the message
              * being enqueued. Use the dequeue context to copy
              * envelope flags for this recipient from the current
              * message to the new message.
              ires = mtaEnqueueTo(nq, adr, len, MTA_DQ_CONTEXT,
              dq, MTA_ENV_TO, 0);
              /* See explanatory comment 7 */
              disp = (ires) ? MTA_DISP_DEFERRED : MTA_DISP_RELAYED;
              CHECK("mtaDequeueRecipientDisposition", mtaDequeueRecipientDisposition(dq, adr, len,disp, 0));
         * A normal exit from the loop occurs when
         * mtaDequeueRecipientNext() returns an MTA_EOF status.
         * Any other status signifies an error.
         if (ires != MTA_EOF)
              error_report(msg_data.options, ires, "mtaDequeueRecipientNext");
              goto done_bad;
         * Begin the MIME decode of the message
         * See explanatory comment 8
         CHECK("mtaDecodeMessage",
              mtaDecodeMessage(
              /* Private context is our message data structure */
              (void *)&msg_data,
              /* Input is the message being dequeued */
              MTA_DECODE_DQ, (void *)dq,
              /* Output is the message being enqueued */
              MTA_DECODE_NQ, (void *)nq,
              /* Inspection routine */
              decode_inspect,
              /* Convert non-MIME formats to MIME */
              MTA_DECODE_THURMAN,
              0));
         * Finish the enqueue
         * NOTE: IT&#25285; IMPORTANT TO DO THIS before DOING THE
         * DEQUEUE. YOU WILL LOSE MAIL IF YOU DO THE DEQUEUE FIRST
         * and then THE ENQUEUE FAILS.
         * See explanatory text 9
         CHECK("mtaEnqueueFinish", mtaEnqueueFinish(nq, 0));
         nq = NULL;
         * Finish the dequeue
         CHECK("mtaDequeueFinish", mtaDequeueMessageFinish(dq, 0));
         * All done with this message
         return(MTA_OK);
    done_bad:
         * Abort any ongoing enqueue or dequeue
         if (nq)
              mtaEnqueueFinish(nq, MTA_ABORT, 0);
         if (dq)
              mtaDequeueMessageFinish(dq, MTA_ABORT, 0);
         * And return our error status
         return(ires);
    #undef CHECK
    * decode_inspect() -- This is the routine that inspects each
    * message part, deciding whether to accept
    * or reject it.
    * See explanatory comment 10
    static int decode_inspect(void *ctx, mta_decode_t *dctx, int data_type,const char *data, size_t data_len)
         char buf[BIGALFA_SIZE * 2 + 10];
         const char *virname;
         int i;
         static unsigned int part_c = 1;
         msg_temp_data_t *msg_data = (msg_temp_data_t *)ctx;
         strncpy(buf,data,data_len);
         buf[data_len] = 0;
         mtaLog("decode_inspect() (%d,%ud): %s",data_type,dctx,buf);
         switch (data_type)
              case MTA_DATA_HEADER:
              * See if the part has:
              * 1. A bad MIME content-type,
              * 2. A bad file name extension in the (deprecated)
              * NAME= content-type parameter, or
              * 3. A bad file name extension in the
              * FILENAME= content-disposition parameter.
              i = 0;
              if ((i = is_bad_mime_type((void *)msg_data->options, dctx, buf, sizeof(buf))) ||
                   is_bad_file_type((void *)msg_data->options,mtaDecodeMessageInfoParams(dctx,MTA_DECODE_CTYPE_PARAMS, NULL),"NAME", buf, sizeof(buf)) ||
                   is_bad_file_type((void *)msg_data->options,mtaDecodeMessageInfoParams(dctx,MTA_DECODE_CDISP_PARAMS, NULL),"FILENAME", buf, sizeof(buf)))
                   char msg[BIGALFA_SIZE*4 + 10];
                   * Replace this part with a text message indicating
                   * that the part&#30196; content has been deleted.
                   * See explanatory comment 11
                   if (i)
                        i = sprintf(msg,
                             "The content of this message part has been removed.\n"
                             "It contained a potentially harmful media type of %.*s",
                             strlen(buf)-2, buf+1);
                   else
                        i = sprintf(msg,
                             "The content of this message part has been removed.\n"
                             "It contained a potentially harmful file named '%s'", buf);
                   mtaLog("decode_inspect(): %s",msg);
                   return(mtaDecodeMessagePartDelete(dctx,
                        MTA_REASON, msg, i,
                        MTA_DECODE_CTYPE, "text", 4,
                        MTA_DECODE_CSUBTYPE, "plain", 5,
                        MTA_DECODE_CCHARSET, "us-ascii", 8,
                        MTA_DECODE_CDISP, "inline", 6,
                        MTA_DECODE_CLANG, "en", 2, 0));
              } break; // case MTA_DATA_HEADER:
              case MTA_DATA_TEXT:
              case MTA_DATA_BINARY:
                   if (msg_data->temp_file == NULL)
                        sprintf(msg_data->temp_file_name,"/tmp/%i.tmp",part_c++);
                        mtaLog("messageDecode(): Opening Temp File %s",msg_data->temp_file_name);
                        msg_data->temp_file = fopen(msg_data->temp_file_name,"wb");
                   fwrite(data,data_len,1,msg_data->temp_file);
                   return(MTA_OK);
                   break;
              case MTA_DATA_NONE:
                   fflush(msg_data->temp_file);
                   fclose(msg_data->temp_file);
                   msg_data->temp_file = NULL;
                   struct cl_limits limits;
                   memset(&limits, 0, sizeof(struct cl_limits));
                   /* maximal number of files in archive */;
                   limits.maxfiles = 1000;
                   /* maximal archived file size */
                   limits.maxfilesize = 10 * 1048576; /* 10 MB */
                   /* maximal recursion level */
                   limits.maxreclevel = 5;
                   /* maximal compression ratio */
                   limits.maxratio = 200;
                   /* disable memory limit for bzip2 scanner */
                   limits.archivememlim = 0;
                   i = cl_scanfile(msg_data->temp_file_name, &virname, NULL, msg_data->options->root,&limits,CL_SCAN_STDOPT);
                   unlink (msg_data->temp_file_name);
                   if(i == CL_VIRUS) {
                        char msg[BIGALFA_SIZE*4 + 10];
                        size_t idlen;
                        i = sprintf(msg,
                             "The content of this message part has been removed.\n"
                             "It contained the virus %s in a file named '%s'", virname,buf);
                        mtaDequeueInfo(dctx,MTA_ENV_ID,&buf,&idlen);
                        buf[idlen] = '\0';
                        mtaLog("decode_inspect(): Detected %s virus in part %i of msg ID %s",virname,0,buf);
                        return(mtaDecodeMessagePartDelete(dctx,
                             MTA_REASON, msg, i,
                             MTA_DECODE_CTYPE, "text", 4,
                             MTA_DECODE_CSUBTYPE, "plain", 5,
                             MTA_DECODE_CCHARSET, "us-ascii", 8,
                             MTA_DECODE_CDISP, "inline", 6,
                             MTA_DECODE_CLANG, "en", 2, 0));
                   } else {
                        if(i != CL_CLEAN)
                             mtaLog("decode_inspect() Error: %s scanning file %s",cl_strerror(i),msg_data->temp_file_name);
                        else
                             mtaLog("decode_inspect(): Part in file %s is clean",msg_data->temp_file_name);
                        //return(mtaDecodeMessagePartCopy(dctx, 0));
                        return(MTA_OK); break;
         return(MTA_OK);
    * is_bad_mime_type() -- See if the part&#30196; media type is in our
    * bad MIME content types, for example:
    * application/vbscript
    * See explanatory comment 13
    static int is_bad_mime_type(our_options_t *options,
    mta_decode_t *dctx, char *buf,
    size_t maxbuflen)
         const char *csubtype, *ctype;
         size_t i, len1, len2;
         char *ptr;
         * Sanity checks
         if (!options || !options->bmt_len ||
              !options->bad_mime_types[0] ||
              !dctx)
              return(0);
         * Get the MIME content type
         ctype = mtaDecodeMessageInfoString(dctx, MTA_DECODE_CTYPE,NULL, &len1);
         csubtype = mtaDecodeMessageInfoString(dctx,MTA_DECODE_CSUBTYPE,NULL, &len2);
         * Build the string: <0x01>type/subtype<0x01><0x00>
         ptr = buf;
         *ptr++ = (char)0x01;
         for (i = 0; i < len1; i++)
              *ptr++ = tolower(*ctype++);
         *ptr++ = '/';
         for (i = 0; i < len2; i++)
              *ptr++ = tolower(*csubtype++);
         *ptr++ = (char)0x01;
         *ptr = '\0';
         * Now see if the literal just built occurs in the list of
         * bad MIME content types
         return((strstr(options->bad_mime_types, buf)) ? -1 : 0);
    * is_bad_file_type() -- See if the part has an associated file
    * name whose file extension is in our list
    * of bad file names, such as .vbs.
    * See explanatory comment 14
    static int is_bad_file_type(our_options_t *options,
    mta_opt_t *params,
    const char *param_name, char *buf,
    size_t maxbuflen)
         const char *ptr1;
         char fext[BIGALFA_SIZE+2], *ptr2;
         size_t i, len;
         * Sanity checks
         if (!options || !options->bft_len || !params || !param_name)
              return(0);
         len = 0;
         buf[0] = '\0';
         if (mtaOptionString(params, param_name, 0, buf, &len,
              maxbuflen - 1) ||
              !len || !buf[0])
              * No file name parameter specified
              return(0);
         * A file name parameter was specified. Parse it to
         * extract the file extension portion, if any.
         ptr1 = strrchr(buf, '.');
         if (!ptr1)
              * No file extension specified
              return(0);
         * Now store the string created earlier in fext[]
         * Note that we drop the &#12539;&#12539;from the extension.
         ptr1++; /* Skip over the &#12539;&#12539;*/
         ptr2 = fext;
         *ptr2++ = (char)0x01;
         len = len - (ptr1 - buf);
         for (i = 0; i < len; i++)
              *ptr2++ = tolower(*ptr1++);
         *ptr2++ = (char)0x01;
         *ptr2++ = '\0';
         * Now return -1 if the string occurs in
         * options->bad_file_types.
         return((strstr(options->bad_file_types, fext)) ? -1 : 0);
    * load_options() -- Load our channel options from the channel&#30196;
    * option file
    * See explanatory comment 15
    static int load_options(our_options_t *options)
         char buf[BIGALFA_SIZE+1];
         size_t buflen, i;
         mta_opt_t *channel_opts;
         int ires;
         const char *ptr0;
         char *ptr1;
         * Initialize the our private channel option structure
         memset(options, 0, sizeof(our_options_t));
         * Set internal defaults for important features
         options->scan_maxsize = 10 * 1024 * 1024; // 10 MB
         options->scan_recursion_level = 10;
         options->scan_maxfiles = 200;
         strcpy(options->db_dir,cl_retdbdir()); // Default ClamAV Directory
         * Access the channel&#30196; option file
         * See explanatory comment 16
         channel_opts = NULL;
         if ((ires = mtaOptionStart(&channel_opts, "/var/opt/SUNWmsgsr/site-programs/msgsr_clamav.cnf", 0, 0)))
              mtaLog("Unable to access our channel option file");
              return(ires);
         * DEBUG=0|1
         options->debug = 0;
         mtaOptionInt(channel_opts, "DEBUG", 0, &options->debug);
         if (options->debug)
              mtaDebug(MTA_DEBUG_SDK, 0);
         * BAD_MIME_TYPES=type1/subtype1[,type2/subtype2[,...]]
         buf[0] = '\0';
         mtaOptionString(channel_opts, "BAD_MIME_TYPES", 0, buf,
         &buflen, sizeof(buf));
         * Now translate the comma separated list:
         * Type1/Subtype1[,Type2/Subtype2[,...]]
         * to
         *<0x01>type1/subtype1[<0x01>type2/subtype2[<0x01>...]]<0x01>
         ptr0 = buf;
         ptr1 = options->bad_mime_types;
         *ptr1++ = (char)0x01;
         for (i = 0; i < buflen; i++)
              if (*ptr0 != ',')
                   *ptr1++ = tolower(*ptr0++);
              else
                   *ptr1++ = (char)0x01;
                   ptr0++;
         *ptr1++ = (char)0x01;
         *ptr1 = '\0';
         options->bmt_len = ptr1 - options->bad_mime_types;
         * BAD_FILE_TYPES=["."]Ext1[,["."]Ext2[,...]]
         buf[0] = '\0';
         buflen = 0;
         mtaOptionString(channel_opts, "BAD_FILE_TYPES", 0, buf,
         &buflen, sizeof(buf));
         * Now translate the comma separated list:
         * ["."]Ext1[,["."]Ext2[,...]]
         * to
         * <0x01>ext1[<0x01>ext2[<0x01>...]]<0x01>
         ptr0 = buf;
         ptr1 = options->bad_file_types;
         *ptr1++ = (char)0x01;
         for (i = 0; i < buflen; i++)
              switch(*ptr0)
                   default : /* copy after translating to lower case */
                        *ptr1++ = tolower(*ptr0++);
                        break;
                   case '.' : /* discard */
                        break;
                   case ',' : /* end current type */
                        *ptr1++ = (char)0x01;
                        ptr0++;
                   break;
         *ptr1++ = (char)0x01;
         *ptr1 = '\0';
         options->bft_len = ptr1 - options->bad_file_types;
         * Dispose of the mta_opt_t context
         * See explanatory comment 17
         mtaOptionFinish(channel_opts);
         * And return a success
         return(MTA_OK);
    * error_report() &#12539;Report an error condition when debugging is
    * enabled.
    static void error_report(our_options_t *options, int ires,
    const char *func)
         if (options->debug)
              mtaLog("%s() returned %d; %s",
                   (func ? func : "?"), ires, mtaStrError(ires,0));
    static void error_reports(our_options_t *options, const char* errStr,
    const char *func)
         if (options->debug)
              mtaLog("%s() reported: %s",
                   (func ? func : "?"), errStr);
    * error_exit() -- Exit with an error status and error message.
    static void error_exit(int ires, const char *msg)
         mtaLog("%s%s%s", (msg ? msg : ""), (msg ? "; " : ""),
         mtaStrError(ires,0));
         exit(1);
    msgsr_clamav.cnf
    DEBUG=1
    BAD_MIME_TYPES=application/vbscript
    BAD_FILE_TYPES=bat,pif,vb,vbs,chs,exe************************************************
    broken message
    Return-path: <[email protected]>
    Received: from virusscan-daemon.apple.california.com by apple.california.com
    (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
    id <[email protected]> for [email protected]; Thu,
    20 Apr 2006 07:30:13 -0700 (PDT)
    Received: from california.com ([209.159.129.16])
    by apple.california.com (Sun Java System Messaging Server 6.2-3.04 (built Jul
    15 2005)) with ESMTP id <[email protected]> for
    [email protected]; Thu, 20 Apr 2006 07:30:05 -0700 (PDT)
    Received: from [61.23.221.222] by apple.california.com (mshttpd); Thu,
    20 Apr 2006 14:30:05 +0000 (GMT)
    Content-return: allowed
    Date: Thu, 20 Apr 2006 14:30:05 +0000 (GMT)
    From: [email protected]
    Subject: Re: testing
    In-reply-to: <[email protected]>
    To: [email protected]
    Message-id: <[email protected]>
    MIME-version: 1.0
    X-Mailer: Sun Java(tm) System Messenger Express 6.2-3.04 (built Jul 15 2005)
    Content-type: multipart/alternative;
    boundary="Boundary_(ID_iOVR4MBjhWJn/mh7Ij+BUQ)"
    Content-language: en
    X-Accept-Language: en
    Priority: normal
    References: <[email protected]>
    Original-recipient: rfc822;[email protected]
    This is a multi-part message in MIME format.
    --Boundary_(ID_iOVR4MBjhWJn/mh7Ij+BUQ)
    Content-type: text/plain; charset=us-ascii
    Content-transfer-encoding: 7bit
    Content-disposition: inline
    Data is missing from here
    ----ec04832708e231d6e2f
    --Boundary_(ID_iOVR4MBjhWJn/mh7Ij+BUQ)
    Content-type: text/html; charset=us-ascii
    Content-transfer-encoding: quoted-printable
    Content-disposition: inline
    Data is missing from here
    nal Message -----=3Cbr=3EFrom=3A chales=40california=2Ecom=3Cbr=3EDate=3A=
    Thursday=2C April 20=2C 2006 11=3A19 pm=3Cbr=3ESubject=3A testing=3Cbr=3E=
    To=3A chales=40california=2Ecom=3Cbr=3E=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B=
    3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B 5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B=
    7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B 9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B=
    1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B 3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B=
    5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B 7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B=
    9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B 1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B=
    3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B 5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B=
    7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B 9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B=
    1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B 3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B=
    5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B 7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B=
    9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B 1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B=
    3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B 5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B=
    7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B 9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B=
    1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B 3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B=
    5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B 7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B=
    9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B 1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B=
    3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B 5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B=
    7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B 9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B=
    1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B 3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B=
    5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B 7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B=
    9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B 1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B=
    3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B 5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B=
    7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B 9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B=
    1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B 3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B=
    5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B 7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B=
    9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B 1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B=
    3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B 5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B=
    7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B 9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B=
    1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B 3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B=
    5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B 7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B=
    9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B 1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B=
    3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B 5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B=
    7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B 9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B=
    1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B 3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B=
    5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B 7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B=
    9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B 1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B=
    3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B 5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B=
    7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B 9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B=
    1=3Cbr=3E=26gt=3B 2=3Cbr=3E=26gt=3B 3=3Cbr=3E=26gt=3B 4=3Cbr=3E=26gt=3B=
    5=3Cbr=3E=26gt=3B 6=3Cbr=3E=26gt=3B 7=3Cbr=3E=26gt=3B 8=3Cbr=3E=26gt=3B=
    9=3Cbr=3E=26gt=3B 0=3Cbr=3E=26gt=3B =3Cbr=3E=26gt=3B
    ----ec04832708e231d6e2f
    --Boundary_(ID_iOVR4MBjhWJn/mh7Ij+BUQ)
    Content-type: text/x-vcard; name=chales.vcf; charset=us-ascii
    Content-transfer-encoding: base64
    Content-disposition: attachment; filename=chales.vcf
    Content-description: Card for <[email protected]>
    bA0KdGVsO3dvcms6NTEwLTI4Ny04NDUwDQp1cmw6aHR0cDovL3d3dy5jYWxpZm9ybmlh
    LmNvbS8NCm9yZzpDYWxpZm9ybmlhQ29tLCBJbmM7DQp2ZXJzaW9uOjIuMQ0KZW1haWw7
    aW50ZXJuZXQ6Y2hhbGVzQGNhbGlmb3JuaWEuY29tDQp0aXRsZTpTeXN0ZW0gQWRtaW5p
    c3RyYXRvcg0KZW5kOnZjYXJkDQo=
    ----ec04832708e231d6e2f--
    Boundary_(ID_iOVR4MBjhWJn/mh7Ij+BUQ)

    Ok, so it's not my code. Using the virus_scanner_simple.c example from SUN, if you change the decode_inspect routine to return MTA_OK for every call (which should technically just let the message pass) it has the same behavior as my program. (Not all that suprising since mine is a derivative of said program)
    That said, this now looks like a library issue. I'm using Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005) according to the SMTP prompt, and was wondering if perhaps I should apply:
    http://sunsolve.sun.com/search/document.do?assetkey=1-21-118207-42-1&searchclause=6306404
    The issue seems to be in the mtaDecodeMessage function, and occurs when the decode_inspect function is allowed to parse the message body, not just the message headers.
    The machine is a Sun Ultra 4500 running Solaris 10. Here's the banner:
    SunOS cookie 5.10 Generic_118822-23 sun4u sparc SUNW,Ultra-Enterprise
    Has anyone else had similar problems using the MTA SDK? Is there anything I'm missing here (besides the above mentioned patch) that might fix this?

  • Issues with changing connection at run-time

    Post Author: dmazourick
    CA Forum: Data Connectivity and SQL
    Weu2019ve tried a lot of different ways to resolve this issue, but are getting every time the different result.
    Probably someone deal with that issue before and know how to correctly resolve it.
    Weu2019re using Crystal Reports Runtime Components X+ (X, XI, XI R2) u2013 all of them has this issue.
    We need client application to connect to multiple data sources u2013 user chooses report, chooses data source and we show the report for specified data source.
    The data sources are tables or stored procedures stored in different databases on different servers.
    For sure, every data source for a single report has the same structure, but that doesnu2019t matter.
    The issue is: when the name of the database on one server is the same as the name of database on second server, the connection caching occurs.
    How we can check that:
    1.       Weu2019re running report for Server1:<DBN> - report shows data from Server1.
    2.       Weu2019re opening second report for Server2:<DBN> - report shows data from Server1.
    3.       Weu2019re closing application and run 1-2 in opposite order, now both reports show data from Server2.
    Weu2019ve tried different approaches u2013 below is a code sample that opens the report for specific connection.
    Juts to be sure that no one will ask u2013 u201CAre you sure youu2019re passing the correct connection info etc.u201D. Yes! We are sure because weu2019re trying to fix this issue for a long time and tried a lot of different approaches and still cannot find the right solution.
    The code looks like below. This is VB6 code, but also the same situation was tried on VC++ 6.0
    Weu2019re not looking into CR.NET solution for now.
    =================================================
    Sub DisplayReport(Server as String, DB as String, UID as String, PWD as String, viewer as Object)
        Dim app As New CRAXDRT.Application
        Dim report As CRAXDRT.report
        Dim database As CRAXDRT.database
        Dim table As CRAXDRT.DatabaseTable
        Dim par As CRAXDRT.ParameterFieldDefinition
        Set report = app.OpenReport("D:\TestReport_X.rpt")
        report.database.LogOnServer "pdssql.dll", Server, DB, UID, PWD
        Set table = report.database.Tables(1)
        table.SetLogOnInfo Server, DB, UID, PWD
        table.Location = table.Name
        report.database.Verify
        viewer.ReportSource = report
        viewer.ViewReport
    end sub
    =================================================
    The result of above code is the following:
    1.       If we will pass the same viewer and will use different Server u2013 the report will be displayed correctly
    2.       If we will pass different viewers and will use different Server u2013 the reports will contain same data
    The result of above code also depends from the version of Crystal Reports the report was designed in:
    1.       For Report designed in 8.5 u2013 passing of the same viewer with same connection info second time will refresh report
    2.       For Report designed in X, XI, XI R2 u2013 no refresh
    Also, a slight modification of the above code helps for reports designed in XI to work properly, but not for reports designed in X and 8.5:
    1.       Before calling LogonServer, make the following: DB = DB & u201C;u201D & Int(rnd()*32767)
    That makes report designed in XI to display properly in different viewers, but doesnu2019t have any impact to X and no any impact to 8.5
    Weu2019re really looking for any help in this question

    Post Author: fburch
    CA Forum: Data Connectivity and SQL
    I am having similar problems and some successes.
    I have 70+ reports and now suddenly I want to point them at two different servers, but at databases with the same name like you talked about.
    I first just tried the following:
    #1. Load report:
    Dim myReport As New ReportDocument
    myReport.Load(filename)
    #2. Pass in parameter values
    ''Get the collection of parameters from the report
    Dim crParameterFieldDefinitions As ParameterFieldDefinitions = r.DataDefinition.ParameterFields
    ''Access the specified parameter from the collection
    Dim crParameter1 As ParameterFieldDefinition = crParameterFieldDefinitions.Item(ParamName)
    ''Get the current values from the parameter field. At this point
    ''there are zero values set.
    'crParameter1Values = crParameter1.CurrentValues
    ''Set the current values for the parameter field
    Dim crDiscrete1Value As New ParameterDiscreteValue
    If crParameter1.ValueType = FieldValueType.DateField Or crParameter1.ValueType = FieldValueType.DateTimeField Then
    If ParamValue Is System.DBNull.Value Then
    crDiscrete1Value.Value = CDate("1/1/1900")
    ElseIf ParamValue Is Nothing Then
    crDiscrete1Value.Value = CDate("1/1/1900")
    Else
    crDiscrete1Value.Value = ParamValue
    End If
    ElseIf crParameter1.ValueType = FieldValueType.StringField Then
    If ParamValue Is Nothing Then
    crDiscrete1Value.Value = ""
    Else
    crDiscrete1Value.Value = ParamValue
    End If
    ElseIf crParameter1.ValueType = FieldValueType.BooleanField Then
    If ParamValue Is Nothing Then
    crDiscrete1Value.Value = False
    ElseIf ParamValue.ToString.ToUpper = "TRUE" Then
    crDiscrete1Value.Value = True
    Else
    crDiscrete1Value.Value = False
    End If
    ElseIf crParameter1.ValueType = FieldValueType.NumberField Then
    If ParamValue Is Nothing Then
    crDiscrete1Value.Value = 0
    Else
    crDiscrete1Value.Value = ParamValue
    End If
    Else
    If ParamValue Is System.DBNull.Value Then
    crDiscrete1Value.Value = Nothing
    ElseIf ParamValue Is Nothing Then
    crDiscrete1Value.Value = Nothing
    Else
    crDiscrete1Value.Value = ParamValue
    End If
    End If
    ''Add the first current value for the parameter field
    Dim crParameter1Values As New ParameterValues
    crParameter1Values.Add(crDiscrete1Value)
    ''All current parameter values must be applied for the parameter field.
    crParameter1.ApplyCurrentValues(crParameter1Values)
    #3 Set "Table Log in info" (most of my reports using stored procedures, but I guess I still needed this step).
    Dim CrTables As Tables = r.Database.Tables
    Dim CrTable As Table
    Dim crtableLogoninfos As New TableLogOnInfos()
    Dim crtableLogoninfo As New TableLogOnInfo()
    With crConnectionInfo
    .ServerName = connectionParser.GetServerName(connectionString)
    .DatabaseName = connectionParser.GetDatabaseName(connectionString)
    If connectionParser.DoesUseIntegratedSecurity(connectionString) = True Then
    .IntegratedSecurity = True
    Else
    .UserID = connectionParser.GetServerUserName(connectionString)
    .Password = connectionParser.GetServerPassword(connectionString)
    .IntegratedSecurity = False
    End If
    End With
    For Each CrTable In CrTables
    crtableLogoninfo = CrTable.LogOnInfo
    crtableLogoninfo.ConnectionInfo = crConnectionInfo
    CrTable.ApplyLogOnInfo(crtableLogoninfo)
    If InStr(CrTable.Location, ".dbo.") = 0 Then
    CrTable.Location = crConnectionInfo.DatabaseName + ".dbo." + CrTable.Location
    End If
    Next
    If r.Subreports.Count > 0 Then
    Dim crSections As Sections
    Dim crSection As Section
    Dim crReportObjects As ReportObjects
    Dim crReportObject As ReportObject
    Dim crSubreportObject As SubreportObject
    Dim crDatabase As Database
    Dim subRepDoc As New ReportDocument()
    'SUBREPORTS
    'Set the sections collection with report sections
    crSections = r.ReportDefinition.Sections
    'Loop through each section and find all the report objects
    'Loop through all the report objects to find all subreport objects, then set the
    'logoninfo to the subreport
    For Each crSection In crSections
    crReportObjects = crSection.ReportObjects
    For Each crReportObject In crReportObjects
    If crReportObject.Kind = ReportObjectKind.SubreportObject Then
    'If you find a subreport, typecast the reportobject to a subreport object
    crSubreportObject = CType(crReportObject, SubreportObject)
    'Open the subreport
    subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
    crDatabase = subRepDoc.Database
    CrTables = crDatabase.Tables
    'Loop through each table and set the connection info
    'Pass the connection info to the logoninfo object then apply the
    'logoninfo to the subreport
    For Each CrTable In CrTables
    crtableLogoninfo = CrTable.LogOnInfo
    crtableLogoninfo.ConnectionInfo = crConnectionInfo
    CrTable.ApplyLogOnInfo(crtableLogoninfo)
    If InStr(CrTable.Location, ".dbo.") = 0 Then
    CrTable.Location = crConnectionInfo.DatabaseName + ".dbo." + CrTable.Location
    End If
    Next
    End If
    Next
    Next
    #4 go get the data
    crv.ReportSource = myReport
    crv.Refresh()
    #5 Call export to disk function.
    This was not changing server - did not realize it was a caching problem as you suggested. That makes sense. So anyway, then of course I threw a verify database statement on there, before I get the data. Now looks like this:
    #1 Load Report
    #2. Pass in parameter values (dummy values that will generate schema of table without having to actually run long running procedures, i.e. select (cast 1 as int) as somefield1, cast(2.0 as numeric(10,0)) as somefield2
    #3 Set "Table Log in info"
    #3b Verify the database which seems to be a necessity:
    myReport.VerifyDatabase()
    #3c Re-populate the report with real parameter values, same as #2 but this time with the ones that will generate the real data
    #4 go get the data
    #5 Call export to disk function.
    This does work, some of the time. When the datasource underlying report are tables, it works. I made a dummy crystal report with lots of different types of params (stored procedure underlying database) - this also worked!
    Unfortunately, when I run this against the majority of my reports, I get this stupid "invalid mapping type value", for which I have not been able to resolve yet.
    I also tried putting a myreport.SetDatabaseLogon("","") -- what would this do, clear it out? (saw this referenced somewhere).
    Then I tried putting the real connection info in there as well ...
    myReport.SetDatabaseLogon(uid, pwd, serverName, DBname)
    I put this setdatabase thing before I called verifydatabase, which is where the process is bombing out and giving me invalid mapping type for the reports that do not run.
    At this point I am still working on solution. I have tried creating dummy report that used same parameter types as a report that was failing and voila - the dummy report worked. Anyway, let me know if you get your problem fixed and I will do the same. Looks like you are using a different method that I didn't notice "LogOnServer"

  • Issue in COPA Report Creation

    Dear All,
    I ave an issue in creation of COPA repor in KE30
    We have created all P&L item as cost element except
    1.Change in WIP for WIP calculation in Product Costing
    2. Price Difference (OBYC- PRD) Variance will be calculated from settlement profile
    Values in COPA are
    1.     VV001  - Quantity (KWBRUM) Quantity field
    2.     VV002 u2013 Price  (PR00) Revenue account of sales (Cost Category 11)
    3.     VV002 -  Material Cost-COGS (VPRS)
    4.     VV003 -  Discount Given (SD Condition)  (Cost Category 12)
    5.     VV005 u2013 Fright (SD Condition)  (Cost Category 12)
    6.     VV005 u2013 Misc Exp (SD  Condition) (Cost Category 12)
    7.     VV006 -  Consumption and Cost of Production, Revaluation, inv diff account
    8.     VV007 u2013 admin expenses
    9.     VV008  - Employees cost
    10.     VV009 u2013 financial cost (interest paid etc deprecation cost, audit exp)
    11.     VV010 u2013 Settlement of Variances of Production order (from settlement profile)
    12.     VV011 - Other income GL accounts (including Exch Rate Diff, profit on sale of asset etc)
    From VV005 to VV009 all the GL account included are created as primary cost element (C category 01)
    and assigned in OKB9 as transfer to PA structure and assigned in PA transfer FI (direct posting form FI)
    VV011 u2013 all the GL account created as Revenue (Cost Category 11)
    Issue we are facing
    1. In Consumption and Cost of Production GL account (Movement type 101 and 261 from production order ) we are not
    able to generate Profit analysis document.
    2. Price difference also come in picture at the time of Stock transfer and Price diff GL account is not created as cost element and how to flow that in copa, price difference from settlement will come from settlement profile.
    Format we have created for COPA report is like
    1.Quantity Field
    2.Selling Price  (PR00)
    3 Material Cost (VPRS)
    4 Discount Given
    5. Fright
    6. Misc Exp
    7. Consumption and Cost of Production, Revaluation, inv diff account
    8 admin expenses
    9. Employees cost
    10. financial cost
    11 Settlement of Variances of Production order
    12. Other income
    13 Net Profit (Calculated Values ) ( 2- 3-4-5-6-7-8-9-10-11+12)
    Is this a correct logic I applied kindly suggest.
    Regards
    Bittu

    Dear All,
    Any suggestion..
    Bittu

  • G/L account no missing in sales order-issue

    Hi Experts,
    I am getting error: G/L account missing while saving the sales order.
    It is available in incompletion log, when i choos that it is going to item conditions tab directly.
    It seems related to VPRS condition type, because that sales order related to free goods sales order.
    There is no pricing condition type, only VPRS condition type is thr.
    Please help us to solve this issue. What would be the reason, is there any costing assignment required?
    Regards
    Lakshmikanth

    Dear Lakshmikanth,
    To analyse the cause of the error:
    VA02 --> Key-in Sales Order No. and Hit "Enter" --> Double Click on to Sales Order Line-item --> Tab: Condition --> Sun-Tab: Analysis
    on to next screen, For your Condition Type, check what condition records are missing.
    This will help you to maintain Relevant Condition Record, to resolve error.
    For Example:
    In VKOA, G/L might not be maintained for Condition Type: KOFI/ KOFK.
    Best Regards,
    Amit
    Note: You may also post the Error-Analysis for our understanding.

  • Cost VPRS in 3rd Party TAB scenario

    Hi,
    we are using 3rd party processing for some of our materials. In this case sales order triggers the purchase requistion and hence purchase order. Then for TAB, do MIGO and then we post invoice verification for this GR. Then we create delivery and finally billing to customer. Now the problem is that in Billing, VPRS is still taking the value of Sales order VPRS value Hence the cost appearing in Billing is not accurate.
    Hence the profit margin calculations are not correct.
    Can anyone suggest the way to populate the value of MIRO in VPRS while billing?
    Interestingly, when using TAS scenario, we are getting the MIRO cost in Billing into VPRS but not so for TAS...
    Thanks

    Hi,
    Inbound delivery is one way of doing it but in our case, the vendor would deliver the goods at out plant and we simply take the stocks into out inventory by MIGO. Even In inbound delivery process, we do goods receipt from the delivery doc itself (hence equivalent to MIGO)
    Now the Vendor sends the invoice in hard copy and we go MIRO w.r.t the PO issued earlier. Now logic says that whatever value we pass in the MIRO should be the actual cost of the product and should be picked up in VPRS in the billing doc for our customer.....
    I dont know whether i have been able to explain this or not.
    And to your question of using TAB instead of TAS....TAB we are using for some vendors who would not deliver directly to our c/s (like in TAS) but would deliver to our plant and we in turn would deliver to ur c/s.

  • Vprs not picking in sales order

    Dear Gurus,
    I am using item category TAN which has "determine cost " activated and my pricing procedure VPRS condition has subtotal as B and requirement is 4.
    After this setting in the sales document condition VPRS is not appearing....is there any setting pending from FI and CO side..
    Please give some inputs
    Aju

    Hi Aju Joseph,
    Check this link you can find the solution for your issue
    VPRS is not determined automatically
    Let me know if your problem is solved
    Regards
    Pradeep

  • VPRS in COPA coresponding to value from goods receipt

    Hi,
    I'm having the following scenario:
    1. Goods receipt from production for finish goods at standard price P1;
    2. Calculation and change of standard price to P2;
    3. Period end closing in CO - variances and settlement to COPA - variances are calculated related to P1;
    4. Goods issue and invoice - VPRS is P2
    I need to know if it is possible to have at the moment of invoice on VPRS the price from the goods receipt. And how can I do that?

    Hi Ajay sir.....
    Correct me if I am wrong, Zara is not saying VPRS value is not the same as PGI. Zara's concern is GR is happening with P1 standard price and PGI is happening with P2 (new cost estimate). Zara wants to have PGI also with the P1 cost estimate. (ultimate aim is to have VPRS value to be picked from GR, i.e. P1 cost estimate ----- in this case)
    Whatever the 1st answer given by you is the ideal one, but Zara's concern is if she uses the previous cost estimate, for this scenario it matches, but if GR and PGI happens in the same period (i.e. current period) there will be a problem, system considers the previous cost estimate instead of current.
    @ ZARA:
    I hope my understanding is right, if not excuse me for misunderstanding.
    And I hope this is the standard behavior....
    Regards....
    Jose

  • Free goods vs financial realated issues -?

    Hi experts
    Please some one can help me to understand free goods related financial issues.
    Ex:
    If  I am giving for  materil 1 quantity 10 ---> materil 1(Inclussive) quatity 2 free.
    so how the financial accounts will be adjusted for the material 1(in my case quatity 2) --?
    Thanks
    Kris

    Hi,
    Free goods has the following limitations:
    - Free goods can only be supported on a 1:1 ratio. This means that an order item can lead to a free goods item. Agreements in the following form are not supported: ‘With material 1, material 2 and material 3 are free of charge‘ or ‘If material 1 and material 2 are ordered at the same time, then material 3 is free of charge‘.
    - Free goods are not supported in combinations with material structures (for example, product selection, BOM, variants with BOM explosion).
    - Free goods are only supported for sales orders with document category C (for example, not quotations).
    - Free goods are not supported for deliveries without reference to a sales order.
    - Free goods cannot be used in make-to-order production, third-party order processing and scheduling agreements.
    - If you defined a free goods for variants in a generic article (only SAP Retail), you can only process the variants in the purchase order and goods receipt individually (as single articles). In other words, you cannot process them using the generic article matrix.
    4.6x
    Not all Sales Order can be used for free goods determination.  You have to check the SD document category if it does not work.  Only category 'C' are supported.  Check transaction VOV8.
    Assume that you want to configure an inclusive FREE goods routine.  Customers must order a minumum quantity of 5 before any free goods can be assign.  For every quantity of 3, the customer will be given 1 free goods.
    WC07 - Maintain Number Range Intervals
    e.g.
    No   From number       To number
    01    0000010000         0000099999
    IMG -> Sales and Distribution -> Basic Functions -> Free Goods ->
    Maintain Access Sequences
    New Entries
    Acsq
    NA00
    Save
    Maintain Condition Types
    New Entries
    Ctyp   Name             AcSq
    FREE  Free Goods    NA00
    Save
    Maintain Pricing Procedures
    Procedures
    New Entries
    Procedure   Description
    FREE           Free Goods
    Select Procedure FREE then click Control data
    Step   Cntr   Ctyp
    10       10      FREE
    V/N6 - Activate Free Goods Determination
    Assign Order Type OR with Document Procedure A with Procedure FREE
    VBN1 - Create free goods determination
    e.g.  FREE inclusive
    Material  Min qty   From   are free good   Calc Rule   Free Goods
                           5           3                1                      1                1
    In this example, if you create a Sales Order for a quantity of 10, SAP will prompt you 7 as the customer order qty and 3 will be free.  Customer only pay for the 7 quantity.
    Hope this may help
    Reward if it helps
    Regards
    Prasanna R

Maybe you are looking for

  • Discoverer with OWB generated EULs

    i configure my warehouse star schema using OWB (warehouse builder 9i release 2) and generated the EUL. the were some warnings but they were pointing to some invalid characters in the names of the objects but the import succeeded. i could see all the

  • ICal crashes on startup on my iPad2

    I then Turned off iCloud synching for calendars on the iPad and deleted the calendars. It started up ok and I was able to add an event. When I turned on iCloud synching again, it immediately crashes on start up. The app doesn't die so to speak in the

  • Mail stops talking to POP server and deletes inbox contents

    Mail has just started playing up: first by refusing to talk to (download from) my pop server (onetel) and then by deleting all the messages in my inbox. The connection doctor says everything is ok and even 'get info' will list messages on the pop ser

  • Java.lang.NoClassDefFoundError in webdynpro application.

    Hi Experts I have developed an webdynpro java applicaton which uses an EJB .The application is working fine on my client machine,but when i try to migrate the project to other client machine and deploy the application it is showing a classpath error.

  • How Would You Handle Carridge Returns & Line Feeds in A Spreadsheet file.

    I have susessfully created a logging program which creates a spreadsheet file. I have additional information added after the loggging data is complete which I have seperated it by a CR/LF. How can I display this particular part of the file only? I ha