How to upload a calculated value

I am a beginner Dreamweaver CS4 user and I am building a website with PHP and MySQL.
My issue will be probably easily solved by any experienced DW user but I couldn't find a solution in tutorials and specialized books.
I have to sell a product and I need that customer fills a Purchase Order. To this purpose I have a HTML form with 3 text fields: "UnitPrice", "Quantity" and "TotalPrice". The customer have to fill the "Quantity" field only because the "UnitPrice" is a constant value and the "TotalPrice" is a calculate value. I am using the Insert Record Server Behavior to upload data and I have no problem with the first two fields that are loaded into the MySQL database normally.
My question is, what is the way to calculate the "TotalPrice" ("UnitPrice" multiplied by "Quantity"), put this value in the appropriate field and upload it into the database?
I'll be very grateful to someone who can give me a hand about that.

Here is the full code for that page
<?php require_once('Connections/Registro.php');
mysql_query("SET NAMES utf8")?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
?>
<?php
// This is a testing variable only that works well but it needs to change the value "10" for the value inserted by the customer
$SubtotalDispositivos = 39.95 * 10
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;  
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  return $theValue;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO Pedidos_Telefonos (emailusuario, preciounitariodispositivo, cantidaddispositivos, subtotaldispositivos, preciounitarioseguro, cantidadseguro, subtotalseguro, costodispositivos, medioenvio, costoenvio, costoimpuestos, totalapagar) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['emailusuario'], "text"),
                       GetSQLValueString($_POST['preciounitariodispositivo'], "double"),
                       GetSQLValueString($_POST['cantidaddispositivos'], "int"),
                       GetSQLValueString($_POST['subtotaldispositivos'], "double"),
                       GetSQLValueString($_POST['preciounitarioseguro'], "double"),
                       GetSQLValueString($_POST['cantidadseguro'], "int"),
                       GetSQLValueString($_POST['subtotalseguro'], "double"),
                       GetSQLValueString($_POST['costodispositivos'], "double"),
                       GetSQLValueString($_POST['medioenvio'], "text"),
                       GetSQLValueString($_POST['costoenvio'], "double"),
                       GetSQLValueString($_POST['costoimpuestos'], "double"),
                       GetSQLValueString($_POST['totalapagar'], "double"));
  mysql_select_db($database_Registro, $Registro);
  $Result1 = mysql_query($insertSQL, $Registro) or die(mysql_error());
  $insertGoTo = "comprartutelefonoprueba2.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  header(sprintf("Location: %s", $insertGoTo));
$colname_DatosIniciales = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_DatosIniciales = $_SESSION['MM_Username'];
mysql_select_db($database_Registro, $Registro);
$query_DatosIniciales = sprintf("SELECT emailusuario FROM Registro_Usuarios WHERE emailusuario = %s", GetSQLValueString($colname_DatosIniciales, "text"));
$DatosIniciales = mysql_query($query_DatosIniciales, $Registro) or die(mysql_error());
$row_DatosIniciales = mysql_fetch_assoc($DatosIniciales);
$totalRows_DatosIniciales = mysql_num_rows($DatosIniciales);
?>
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/masinformacion.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Información adicional</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="oneColLiqCtrHdr.css" rel="stylesheet" type="text/css" />
</head>
<body class="oneColLiqCtrHdr">
<div class="oneColLiqCtrHdr" id="container">
  <div id="header"><a href="http://www.tullaveausa.com"><img src="images/logo azul.jpg" alt="tu-llave-a-USA" width="323" height="77" align="middle" /></a>
    <!-- end #header --></div>
  <!-- InstanceBeginEditable name="Contenido" -->
  <div id="mainContent">
    <h1>Comprar  dispositivo(s) telefónico(s) PRUEBA (último)</h1>
    <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
      <p>Cálculo de costos en Dólares de los Estados Unidos (usar formato con punto decimal y dos dígitos decimales).</p>
      <h3><strong>1. Costo del(los) Dispositivo(s)</strong>
        <input name="emailusuario" type="hidden" id="emailusuario" value="<?php echo $row_DatosIniciales['emailusuario']; ?>" />
        <?php echo $row_DatosIniciales['emailusuario']; ?></h3>
      <blockquote>
        <table width="443" border="1" align="center">
          <caption>
            <strong>Tabla 1. Costo del(los) dispositivo(s) </strong>
          </caption>
          <tr align="center">
            <td width="166"><strong>1. Concepto</strong></td>
            <td width="75"><strong>2. Precio Unitario</strong></td>
            <td width="71"><strong>3. Cantidad</strong></td>
            <td width="103"><strong>4. Subtotal (Col. 2 X Col.3)</strong></td>
          </tr>
          <tr>
            <td>Dispositivo(s) magicJack:</td>
            <td align="center"><input name="preciounitariodispositivo" type="text" id="preciounitariodispositivo" value="39.95" size="8" maxlength="10" readonly="readonly" /></td>
            <td align="center"><input name="cantidaddispositivos" type="text" id="cantidaddispositivos" value="1" size="2" maxlength="2" />
            *</td>
            <td align="center"><input name="subtotaldispositivos" type="text" id="subtotaldispositivos" value="<?php echo $SubtotalDispositivos; ?>" size="8" maxlength="10" readonly="readonly" /></td>
          </tr>
          <tr>
            <td>Seguro por pérdida o daño (opcional)*:</td>
            <td align="center"><input name="preciounitarioseguro" type="text" id="preciounitarioseguro" value="5.00" size="8" maxlength="10" readonly="readonly" /></td>
            <td align="center"></span>
              <input name="cantidadseguro" type="text" id="cantidadseguro" value="0" size="2" maxlength="2" />
            *</td>
            <td align="center"><input name="subtotalseguro" type="text" id="subtotalseguro" size="8" maxlength="10" readonly="readonly" /></td>
          </tr>
          <tr>
            <td colspan="3"><strong>TOTAL DIPOSITIVO(S)</strong> (Suma columna 4):</td>
            <td align="center"><span id="sprytextfield14">
              <input name="totaldispositivos" type="text" id="totaldispositivos" size="8" maxlength="10" readonly="readonly" />
            </span></td>
          </tr>
        </table>
        <blockquote>
          <blockquote>
            <p>Nota: Sólo llenar los campos marcados con * y luego ir a la Tabla 3</p>
          </blockquote>
        </blockquote>
      </blockquote>
      <h3><strong>2. Costo de manipuleo y envío</strong></h3>
      <table width="623" border="1" align="center">
        <tr>
          <th width="228" scope="col">Destino</th>
          <th width="101" align="center" scope="col">Correo aéreo regular*</th>
          <th width="98" align="center" scope="col">Correo aéreo certificado*</th>
          <th width="88" align="center" scope="col">Express Mail Service</th>
          <th width="74" align="center" scope="col">Fed-Ex Courier</th>
        </tr>
        <tr>
          <td scope="row">Estados Unidos (continental)</td>
          <td align="center">6.95</td>
          <td align="center">N/A</td>
          <td align="center">N/A</td>
          <td align="center">N/A</td>
        </tr>
        <tr>
          <td scope="row">México y Canadá</td>
          <td align="center">8.50</td>
          <td align="center">18.50</td>
          <td align="center">29.00</td>
          <td align="center">34.00</td>
        </tr>
        <tr>
          <td scope="row">Centro y Sudamérica (incluye Alaska y Puerto Rico)</td>
          <td align="center">12.00</td>
          <td align="center">22.00</td>
          <td align="center">34.00</td>
          <td align="center">45.00</td>
        </tr>
        <tr>
          <td scope="row">Europa, Asia, África y Oceanía (incluye Hawaii)</td>
          <td align="center">12.50</td>
          <td align="center">22.50</td>
          <td align="center">45.00</td>
          <td align="center">50.00</td>
        </tr>
        <caption>
          <strong>Tabla 2: Costo de manipuleo y envío para 1 ó 2 dispositivos</strong>
        </caption>
      </table>
      <blockquote> </blockquote>
      <h4>3. Costo total </h4>
      <table width="616" border="1" align="center">
        <caption>
          <strong>Tabla 4. Costo total </strong>
        </caption>
        <tr>
          <th width="383" scope="col">Concepto</th>
          <th width="126" align="center" scope="col">Medio de envío elgido</th>
          <th width="85" align="center" scope="col">Costo</th>
        </tr>
        <tr>
          <td colspan="2" align="left" scope="row">Costo del(los) dispositivo(s) (Total Tabla 1.):</td>
          <td align="left"><input name="costodispositivos" type="text" id="costodispositivos" size="8" maxlength="8" readonly="readonly" /></td>
</tr>
        <tr>
          <td align="left" scope="row">Costo de envío (Valor correspondiente Tabla 2 ó 3.):</td>
          <td align="left"><input name="medioenvio" type="text" id="medioenvio" size="15" maxlength="25" />
          *</td>
          <td align="left"><input name="costoenvio" type="text" id="costoenvio" size="8" maxlength="8" />
          *</td>
</tr>
        <tr>
          <td colspan="2" align="left" scope="row">Impuestos (6%):</td>
          <td align="left"><input name="costoimpuestos" type="text" id="costoimpuestos" size="8" maxlength="8" readonly="readonly" /></td>
</tr>
        <tr>
          <th colspan="2" align="left" scope="row">TOTAL A PAGAR (Subtotal + impuestos):</th>
          <td align="left"><input name="totalapagar" type="text" id="totalapagar" size="8" maxlength="8" readonly="readonly" /></td>
</tr>
</table>
      <blockquote>
        <blockquote>
          <blockquote>
            <p>Nota: Sólo llenar los campos marcados con * y luego presionar &quot;Calcular valores&quot;</p>
          </blockquote>
        </blockquote>
      </blockquote>
      <table width="200" border="0" align="center">
        <tr>
          <td align="right"><input type="reset" name="cancelar" id="cancelar" value="Cancelar" /></td>
          <td align="left"><input type="submit" name="calcular" id="calcular" value="Calcular valores" /></td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form1" />
    </form>
    <hr />
    <p><a href="obtenertutelefono.php">Volver a &quot;obtener un nuevo teléfono&quot;</a> (anulando proceso de compra)</p>
    <p><a href="principalcuenta.php">Volver a tu cuenta</a>
      <!-- end #mainContent -->
      (anulando proceso de compra)</p>
    <p> </p>
    <!-- end #mainContent -->
  </div>
<!-- InstanceEndEditable -->
  <div id="footer">
    <!-- end #footer -->
  </div>
<!-- end #container --></div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($DatosIniciales);
?>

Similar Messages

  • How can i pass calculated value to internal table

    Hi
    i have to pass calculated value into internal table
    below field are coming from database view and i' m passing view data into iznew1
    fields of iznew1
                 LIFNR  LIKE EKKO-LIFNR,
                 EBELN  LIKE EKKO-EBELN,
                 VGABE  LIKE EKBE-VGABE,
                 EBELP  LIKE EKBE-EBELP,
                 BELNR  LIKE EKBE-BELNR,
                 MATNR  LIKE EKPO-MATNR,
                 TXZ01  LIKE EKPO-TXZ01,
            PS_PSP_PNR  LIKE EKKN-PS_PSP_PNR,
                 KOSTL  LIKE EKKN-KOSTL,
                 NAME1  LIKE LFA1-NAME1,
                 NAME2  LIKE LFA1-NAME2,
                 WERKS  LIKE EKPO-WERKS,
                 NETWR  LIKE EKPO-NETWR,
                 KNUMV  LIKE EKKO-KNUMV,
                 GJAHR  LIKE EKBE-GJAHR,
    and now i want to pass
    one field ED1  which i has calculated separatly and i want to pass this value into iznew1
    but error is coming that iznew1 is a table with out header line  has no component like ED1.
    so how can i pass calculated value to internal table iznew1,

    When you declare your internal table , make an addtion occurs 0
    eg . data : begin of iznew occurs 0 ,
                    fields ...
       add the field here ed1.
               end of iznew.
    now when you are calculating the value of ed1,
    you can pass the corresponding value of  ed1 and modify table iznew.
    eg
    loop at iznew.
    iznew-ed1 = ed1.
    modify iznew.
    endloop.

  • How to populate the calculated value into screen field.

    I am doing one enhancement in QM.I have added one custom screen to notification transaction ( QM01/QM02/QM03) transaction tab strip control using the enhancement QQMA0001.The Details of the calling and called screens as shown bellow
    The Calling screen: SAPLIQS0
    Screen Number: 7790
    Screen Area :USER0001
    Called Screen: SAPLXQQM
    Screen Number: 0101
    I have developed the Custom Screen in screen 0101 and called in PBO of program SAPLIQS0 7790 screen.
    The Screen in calling perfectly .The Custom screen having different fields like Raw cost, Intermediate cost, Finished cost, SCAR Cost and Sales Order Cost Etc... These fields are out put filed types. No input for these screens.. I have few doubts regarding this
    How to populate the calculated values in Custom screen?
    Where we wrote the code to populate the calculated values in custom screen?
    You have any idea please guide me
    Thanks & Regards,
    Samantula

    As your screen fields should be global variables in SAPLXQQM, you may initialize them by implementing function module EXIT_SAPMIWO0_008 which also belongs to SAPLXQQM (Customer Exit: Transfer Notification Data to User Screen)

  • How to upload two different asset values for Book & Tax Depre in FA

    Hello all
    kindly let me know how to resolve a situation where we have different methods of calculating Depreciation. For Example SLM for Book Depreciation and Diminishing method for Tax Depreciation.
    To calculate depreciation we use straight line method for book depreciation and diminishing value method for Tax depreciation. In this case, we have 2 different asset values to calculate book and tax depreciation.
    Since SAP allows to upload only one asset value (Gross book value), I get correct book depreciation value but incorrect value for tax depreciation as the tax depreciation is calculated based on gross book value instead of net book value (gross book value less accumulated depreciation value).
    For Eg
    FOR THE FIRST YEAR 
    BOOK DEPRECIATION:
    Asset Value = 1000
    Depreciation Method : SLM
    Depreciation rate is 10%
    Depreciation Amount = 100
    TAX DEPRECIATION:
    Asset Value = 1000
    Depreciation Method : DIMINISHING METHOD
    Depreciation rate is 15%
    Depreciation Amount = 150
    FOR THE SECOND YEAR
    BOOK DEPRECIATION:
    Asset Value = 1000
    Depreciation Method : SLM
    Depreciation rate is 10%
    Depreciation Amount = 100
    TAX DEPRECIATION:
    Asset Value = 850
    Depreciation Method : DIMINISHING METHOD
    Depreciation rate is 15%
    Depreciation Amount = 127.5
    KINDLY LET ME KNOW HOW TO UPLOAD THE PAST DATA WITH TWO DIFFERENT ASSET VALUES (IE 1000 & 850)  FOR THE ABOVE.
    Regards
    Sushil Yadav

    Hi K,
    I'm having the same problem...did you find a solution yet?
    Greets,
    Martin.

  • How  to expand rows in a table by calculated value of a field

    Hi,
    I'm trying to set the rows of an expandable table to follow the calculated value of a field.
    The calculated field comes from two date fields that calculate the number of days and I want my table/row to expand based on that number..
    Is is possible? Right now I have a button that does add an instance  "Admin_Use.Table3._Row1.addInstance(1);" but I want it to be triggered by the calculated field instead...
    Thank you so much!!!!

    Hi Niall,
    Thank you for your reply. I'm still a bit puzzled as right now I have this code in my calculate field (see below) under the calculated event and I'm not sure how to insert the code you sent me as I keep getting syntax errors. Any help will be greatly appreciated!!!
    if (HasValue(Nights.FirstNight) & HasValue(Nights.LastNight) ) then
        if (Date2Num(Nights.LastNight, "YYYY-MM-DD", "en_IE") >= Date2Num(Nights.FirstNight, "YYYY-MM-DD", "en_IE")) then
            $ = Date2Num(Nights.LastNight, "YYYY-MM-DD", "en_IE") - Date2Num(Nights.FirstNight, "YYYY-MM-DD", "en_IE") + 1
    else
            xfa.host.messageBox ("The first night cannot be after the last night", "Nights Covered", 0)
            Nights.LastNight.rawValue = null
    endif
    else
    endif

  • How to upload a CRM sales order to R/3 after modifying some values in CRM

    Hi All
    How to upload a CRM sales order to R/3 after modifying  some values in CRM ?
    In other words
      You have a Sales Order in CRM. While sending this Sales Order to R/3, we would like to modify certain values in the Order before it is replicated to R/3 . How do u do that?
    Thanks
    Jaman
    Message was edited by: Sap_Crm_Guy
    Message was edited by: Sap_Crm_Guy

    Hi Jaman,
    Try to have a look at the function group CRM_ORDER_API. In there you will find several useful functions. CRM_MAINTAIN_ORDER can most probably do what you want to do, but it is not simple to figure out how to use it as it is not very well documented.
    There is a BADI called ORDER_SAVE with three methods that you can implement. This BADI allows you to manipulate the order before it is saved and before it is replicated to R/3.
    Very best regards,
    Anders Mørk

  • How to paste calculated values from Numbers?

    When I copy calculated values from Numbers and paste into a table in Pages, I get an image like the one below.  Non calculated values paste fine.
    To get around this issue, I paste the calculated values into TextWrangler, then copy from there and paste into Pages.  Is there a way to go directly from Numbers to Pages with calculated values?

    Hi 4th Space,
    I you are pasting into a table in Pages, follow Jeffs instructions.
    I you are not pasting into a table, this works. Copy the cells in Numbers. Go to your Pages document and under the Edit Menu > Paste and Match Style. It works like Paste Values.
    Ian.

  • How to upload values for Territory attributes.

    Hi Is there any standard SAP practice to upload territory attribute values. i could see we can upload territory structure in sap. but attribute values is there any way ?
    thanks
    chap

    Hi Chap,
    If you are planning to create territory attributes via CRM GUI then please refer to the below link. This is what immediately I can suggest. Meanwhile I will let you know the programmatic approach if I find one.
    Re: To Add attribute in Territory Management
    <b>Reward if helps</b>
    Regards,
    Paul Kondaveeti

  • How to upload file from desktop or C drive and send as attachments

    Hello Experts,
    Please tell me
    How to upload jpg or gif or drawing files from desktop or any drive and store into R/3 by the same time I have to send mail as a attachment.
    I heard that FM
    SO_NEW_DOCUMENT_ATT_SEND_API1  is only to send as a  attachment what ever the data is present in the internal table only.
    please help me on that.

    I m using this code its having attachment but I m not able to open the file. Please help me
    I m using gui_upload to upload the file
    PROGRAM  ZTEST
           no standard page heading line-size 255.
    DATA: xfile TYPE string.
    data :     t_IW51 LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: OBJPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    DATA: OBJHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: OBJBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: OBJTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: RECLIST   LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
    DATA: DOC_CHNG  LIKE SODOCCHGI1.
    DATA: TAB_LINES LIKE SY-TABIX.
    data :  email type table of BAPIADSMTP.
    PARAMETERS : file LIKE rlgrap-filename OBLIGATORY.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
      CLEAR file.
      CALL FUNCTION 'F4_FILENAME'
        IMPORTING
          file_name = file.
      xfile = file.
    START-OF-SELECTION.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename            = xfile
          filetype            = 'ASC'
          has_field_separator = 'X'
        TABLES
          data_tab            = t_IW51.
    Creation of the document to be sent
    File Name
      DOC_CHNG-OBJ_NAME = 'SENDFILE'.
    Mail Subject
      DOC_CHNG-OBJ_DESCR = 'Send External Mail'.
    Mail Contents
      OBJTXT = 'Minimum bid : $250000'.
      APPEND OBJTXT.
      OBJTXT = 'A representation of the pictures up for auction'.
      APPEND OBJTXT.
      OBJTXT = 'was included as attachment.'.
      APPEND OBJTXT.
      DESCRIBE TABLE OBJTXT LINES TAB_LINES.
      READ TABLE OBJTXT INDEX TAB_LINES.
      DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    Creation of the entry for the compressed document
      CLEAR OBJPACK-TRANSF_BIN.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'RAW'.
      APPEND OBJPACK.
    Creation of the document attachment
    (Assume that the data in OBJBIN is in BMP format)
    *OBJBIN = ' \O/ '. APPEND OBJBIN.
    *OBJBIN = ' | '. APPEND OBJBIN.
    *OBJBIN = ' / \ '. APPEND OBJBIN.
      OBJBIN[] = t_IW51[].
      DESCRIBE TABLE OBJBIN LINES TAB_LINES.
      OBJHEAD = 'PICTURE.PDF'.
      APPEND OBJHEAD.
      OBJBIN[] = t_IW51[].
    Creation of the entry for the compressed attachment
      OBJPACK-TRANSF_BIN = 'X'.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 1.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'PDF'.
      OBJPACK-OBJ_NAME = 'PICTURE'.
      OBJPACK-OBJ_DESCR = 'Representation of object 138'.
      OBJPACK-DOC_SIZE = TAB_LINES * 255.
      APPEND OBJPACK.
    Completing the recipient list
      RECLIST-RECEIVER = 'email_id have to enter here'.
      RECLIST-REC_TYPE = 'U'.
      APPEND RECLIST.
      RECLIST-RECEIVER = 'ENTEG01'.
      RECLIST-REC_TYPE = 'P'.
      APPEND RECLIST.
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
         DOCUMENT_DATA = DOC_CHNG
         PUT_IN_OUTBOX = 'X'
         commit_work = 'X'
      TABLES
         PACKING_LIST = OBJPACK
         OBJECT_HEADER = OBJHEAD
         CONTENTS_BIN = OBJBIN
         CONTENTS_TXT = OBJTXT
         RECEIVERS = RECLIST
    *EXCEPTIONS
      TOO_MANY_RECEIVERS = 1
      DOCUMENT_NOT_SENT = 2
      OPERATION_NO_AUTHORIZATION = 4
    *OTHERS = 99.
      CASE SY-SUBRC.
        WHEN 0.
          WRITE: / 'Result of the send process:'.
          LOOP AT RECLIST.
            WRITE: / RECLIST-RECEIVER(48), ':'.
            IF RECLIST-RETRN_CODE = 0.
              WRITE 'The document was sent'.
            ELSE.
              WRITE 'The document could not be sent'.
            ENDIF.
          ENDLOOP.
        WHEN 1.
          WRITE: / 'No authorization for sending to the specified number',
                   'of recipients'.
        WHEN 2.
          WRITE: / 'Document could not be sent to any recipient'.
        WHEN 4.
          WRITE: / 'No send authorization'.
        WHEN OTHERS.
          WRITE: / 'Error occurred while sending'.
      ENDCASE.

  • How to know the dynamic values for this :AND category_id_query IN (1, :3, )

    Hi Team,
    R12 Instance :
    Oracle Installed Base Agent User Responsibility --> Item Instances -->
    Item Instance: Item Instances > View : Item Instance : xxxxx> Contracts : Item Instance : xxxxx> Service Contract: xxxxx>
    In the above page there are two table regions.
    Notes.
    -------------------------------------Table Region---------------------------
    Attachments
    -------------------------------------Table Region---------------------------
    --the attachments are shown using the query from the fnd_lobs and fnd_docs etc...
    I want to know what are the document types are displayed in this page ?
    --We developed a custom program to attach the attachments to the  services contracts and the above seeded OAF page displays those ..as needed.
    But after recent changes..the Attachments--> table region is not showing the attachments.
    I have verified the query..and could not find any clue in that..
    but i need some help if you guys can provide..
    SELECT *
    FROM
    *(SELECT d.DOCUMENT_ID,*
    d.DATATYPE_ID,
    d.DATATYPE_NAME,
    d.DESCRIPTION,
    DECODE(d.FILE_NAME, NULL,
    *(SELECT message_text*
    FROM fnd_new_messages
    WHERE message_name = 'FND_UNDEFINED'
    AND application_id = 0
    AND language_code  = userenv('LANG')
    *), d.FILE_NAME)FileName,*
    d.MEDIA_ID,
    d.CATEGORY_ID,
    d.DM_NODE,
    d.DM_FOLDER_PATH,
    d.DM_TYPE,
    d.DM_DOCUMENT_ID,
    d.DM_VERSION_NUMBER,
    ad.ATTACHED_DOCUMENT_ID,
    ad.ENTITY_NAME,
    ad.PK1_VALUE,
    ad.PK2_VALUE,
    ad.PK3_VALUE,
    ad.PK4_VALUE,
    ad.PK5_VALUE,
    d.usage_type,
    d.security_type,
    d.security_id,
    ad.category_id attachment_catgeory_id,
    ad.status,
    d.storage_type,
    d.image_type,
    d.START_DATE_ACTIVE,
    d.END_DATE_ACTIVE,
    d.REQUEST_ID,
    d.PROGRAM_APPLICATION_ID,
    d.PROGRAM_ID,
    d.category_description,
    d.publish_flag,
    DECODE(ad.category_id, NULL, d.category_id, ad.category_id) category_id_query,
    d.URL,
    d.TITLE
    FROM FND_DOCUMENTS_VL d,
    FND_ATTACHED_DOCUMENTS ad
    WHERE d.DOCUMENT_ID = ad.DOCUMENT_ID
    *) QRSLT*
    WHERE ((entity_name    ='OKC_K_HEADERS_V'-- :1
    AND pk1_value          IN ( 600144,599046) --:2
    AND category_id_query IN (1, :3, :4, :5, :6, :7) )
    AND datatype_id       IN (6,2,1,5)
    AND (SECURITY_TYPE     =4
    OR PUBLISH_FLAG        ='Y')))
    --='000180931' -- 'ADP118'
    The above seeded query is the one which is used for table region to retrieve the data..
    how to know the dynamic values for this : AND category_id_query IN (1, :3, :4, :5, :6, :7) )
    --Sridhar                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Hi Patricia,
    is it working for restricted key figure and calculated key figure ??
    Note Number Fisc Period Opening Days
    1 1 2
    2 1 3
    3 1 0
    because I have other restriction, so I create two restricted key figure..
    RK1  with restriction :  Total Number of Note,
    RK2  with restriction :  Total Opening Days ,
    then I Created a calculated key figure, average opening days in a period
    CK1 = RK2 / RK1..
    in this case, I am not sure if it will work or not..
    for example, during RK2 calclation, it might be this   2+3 = 5, the line with 0 will be ignored..
    during RK1 calcualtion, it might be 1 + 1 + 1 = 3. ---> Not sure in this case, the line with opening days 0 will be calculated or not..
    could you please confirm..

  • How to check for null value/field?

    Hi!
    I have created a form that is designed to calculate the rows using the FormCalc function.
    My problem is that if I have no value in the some of the rows, a 0 is automatically display as the calculated output field. If a row has no data, how can I get a null or blank field in the result (calculated field) field?
    Let's say, I have 5 rows and each row should have a calculated value in one of the fields; when I fill out only two of the rows, the remaining three rows come out with 0s in the calculated output field. I need a blank output field for the remaining calculated values instead of 0s. I am a newbie so please excuse me if I am not explaining well.
    Thanks
    Jofar1

    This is the value that I have on my calculate event: "Rate*Units_of_ServiceRow2".
    How should/can I incorporate the two codes?

  • HOW TO UPLOAD DATA FROM EXCEL TO INTERNALTABLE

    HI,
    HOW TO UPLOAD DATA FROM EXCEL TO INTERNALTABLE?  & WITH EXAMPLE.

    hi,
    chk this, put the data into an excel file.
    fields inside it are name and age.
    sample excel sheet.
    coloumn 1 is name and column 2 is age
    name age
    A     8
    C     13
    D     55
    DATA : int_excel LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
    data : record like db_name_age occurs 0 with header line.
    DATA : v_start_col TYPE i VALUE '1', "starting col
           v_start_row TYPE i VALUE '1', " starting row
           v_end_col   TYPE i VALUE '2', " total columns
           v_end_row   TYPE i VALUE '10'. "total no of record
    FORM f_upload .
      CLEAR : int_excel, int_excel[].
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = wf_filename
          i_begin_col             = v_start_col
          i_begin_row             = v_start_row
          i_end_col               = v_end_col
          i_end_row               = v_end_row
        TABLES
          intern                  = int_excel
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
    *Message is 'Unable to upload data from  '  wf_filename.
        MESSAGE e169(zm050) WITH wf_filename.
      ELSE.
        SORT int_excel BY row col.
        REFRESH : record.
        CLEAR   : record.
        LOOP AT int_excel.
          CASE int_excel-col. "go thru each column.
            WHEN 1.
              record-name  = int_excel-value.
            WHEN 2.
              record-age = int_excel-value.     
          ENDCASE.
          AT END OF row.
            APPEND record.
            CLEAR record.
          ENDAT.
        ENDLOOP.
    *inserting into table
    modfiy db_name_age from table record.
      ENDIF.
    <i><b>ANOTHER EXAMPLE</b></i>
    TYPE-POOLS truxs.
    types: begin of t_tab,
    col1(5) type c,
    col2(5) type c,
    col3(5) type c,
    end of t_tab.
    data : itab type standard table of t_tab,
           wa type t_tab.
    data it_type type truxs_t_text_data.
    parameter p_file type rlgrap-filename.
    data ttab type tabname.
    at selection-screen on value-request for p_file.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    PROGRAM_NAME = SYST-CPROG
    DYNPRO_NUMBER = SYST-DYNNR
    FIELD_NAME = 'P_FILE'
    IMPORTING
    FILE_NAME = p_file
    start-of-selection.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
    I_FIELD_SEPERATOR =
    I_LINE_HEADER = 'X'
    i_tab_raw_data = it_type
    i_filename = p_file
    tables
    i_tab_converted_data = itab[]
    EXCEPTIONS
    CONVERSION_FAILED = 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.
    end-of-selection.
    loop at itab into wa.
    write : wa-col1,
            wa-col2,
            wa-col3.
    endloop.
    rgds,
    anver
    <i>if hlped pls mark points</i>

  • How to upload data from excel to SAP and options to be used

    How to upload data from excel to SAP and options to be used
    thank you,
    Regards,
    Jagrut Bharatkumar shukla

    Hi Jagrut,
        You can use gui_upload.
    chk the sample program mentioned below.
    REPORT ZFTP .
    DATA: BEGIN OF I_FILE OCCURS 0,
    DATA(2000) TYPE C,
    END OF I_FILE.
    DATA: BEGIN OF I_FILE2 OCCURS 0,
    DATA(2000) TYPE C,
    END OF I_FILE2.
    DATA: W_COUNT TYPE I.
    PARAMETERS: P_FILEN TYPE STRING,
    P_FILE2 TYPE STRING,
    P_NUM(4) TYPE N..
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILEN.
    PERFORM F_FILE_GET USING P_FILEN TEXT-G01.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE2.
    PERFORM F_FILE_GET USING P_FILE2 TEXT-G01.
    START-OF-SELECTION.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = P_FILEN
    FILETYPE = 'ASC'
    HAS_FIELD_SEPARATOR = 'X'
    HEADER_LENGTH = 0
    READ_BY_LINE = 'X'
    DAT_MODE = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    CHECK_BOM = ' '
    VIRUS_SCAN_PROFILE =
    NO_AUTH_CHECK = ' '
    IMPORTING
    FILELENGTH =
    HEADER =
    tables
    data_tab = I_FILE
    IF SY-SUBRC <> 0.
    MESSAGE E024(Z1).
    ENDIF.
    LOOP AT I_FILE.
    W_COUNT = W_COUNT + 1.
    IF NOT W_COUNT > P_NUM.
    MOVE I_FILE TO I_FILE2.
    APPEND I_FILE2.
    ENDIF.
    ENDLOOP.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE =
    filename = P_FILE2
    FILETYPE = 'ASC'
    APPEND = ' '
    WRITE_FIELD_SEPARATOR = 'X'
    HEADER = '00'
    TRUNC_TRAILING_BLANKS = ' '
    WRITE_LF = 'X'
    COL_SELECT = ' '
    COL_SELECT_MASK = ' '
    DAT_MODE = ' '
    CONFIRM_OVERWRITE = ' '
    NO_AUTH_CHECK = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    WRITE_BOM = ' '
    TRUNC_TRAILING_BLANKS_EOL = 'X'
    WK1_N_FORMAT = ' '
    WK1_N_SIZE = ' '
    WK1_T_FORMAT = ' '
    WK1_T_SIZE = ' '
    IMPORTING
    FILELENGTH =
    tables
    data_tab = I_FILE2
    FIELDNAMES =
    *& Form F_FILE_GET
    text
    -->P_P_FILEN text
    -->P_TEXT_G01 text
    FORM F_FILE_GET USING L_FILENA L_TEXT.
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
    DEF_FILENAME = ' '
    DEF_PATH = ' '
    MASK = ',.,*.TXT.'
    MODE = 'O'
    TITLE = L_TEXT
    IMPORTING
    FILENAME = L_FILENA
    rc =
    EXCEPTIONS
    INV_WINSYS = 1
    NO_BATCH = 2
    SELECTION_CANCEL = 3
    SELECTION_ERROR = 4
    OTHERS = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Reward if helpful.
    Regards,
    Harini.S

  • How to upload Excel data in Ztables fastly & easily.

    Dear ALL,
    I  want to compare material codes in 2 different excel sheets.
    I have downloaded output from 2 different SQVI into 2 different excel sheets.
    Now I want to compare these 2 sheets to get matching codes or unmatching codes.
    I can use VLOOKUP in excel also. But How can I make use of ABAP by downloading these excel data in 2 different Ztables and compare these 2 tables with some user defined TC (transaction code) ?
    For this activity How to upload Excel data(2 sheets) in 2 Ztables fastly & easily ?
    Is there any method other than SCAT , BDC and LSMW  ???
    Or which is best method in above ?
    Pl' reply.
    Thanks.

    Have a look at the program
    *: Description                                                :
    *: This is a simple example program to get data from an excel :
    *: file and store it in an internal table.                    :
    *: Author : www.sapdev.co.uk, based on code from Jayanta      :
    *: SAP Version : 4.7                                          :
    REPORT  zupload_excel_to_itab.
    TYPE-POOLS: truxs.
    PARAMETERS: p_file TYPE  rlgrap-filename.
    TYPES: BEGIN OF t_datatab,
          col1(30)    TYPE c,
          col2(30)    TYPE c,
          col3(30)    TYPE c,
          END OF t_datatab.
    DATA: it_datatab type standard table of t_datatab,
          wa_datatab type t_datatab.
    DATA: it_raw TYPE truxs_t_text_data.
    At selection screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          field_name = 'P_FILE'
        IMPORTING
          file_name  = p_file.
    *START-OF-SELECTION.
    START-OF-SELECTION.
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
        I_FIELD_SEPERATOR        =
          i_line_header            =  'X'
          i_tab_raw_data           =  it_raw       " WORK TABLE
          i_filename               =  p_file
        TABLES
          i_tab_converted_data     = it_datatab[]    "ACTUAL DATA
       EXCEPTIONS
          conversion_failed        = 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.
    END-OF-SELECTION.
    END-OF-SELECTION.
      LOOP AT it_datatab INTO wa_datatab.
        WRITE:/ wa_datatab-col1,
                wa_datatab-col2,
                wa_datatab-col3.
      ENDLOOP.
    Message was edited by:
            K N  REDDY

  • Calculating values from row to row with pure sql?

    Hello,
    I'm searching for a way to calculate values from row to row with pure sql. I need to create an amortisation table. How should it work:
    Known values at start: (they can be derived with an ordinary sql-statement)
    - redemption amount RA
    - number of payment terms NT
    - annuity P (is constant in every month)
    - interest rate IR
    What has to be calculated:
    First row:
    RA1 = RA - P
    Z1 = (RA1 * (IR/100/12))
    T1 = P - Z1
    2nd row
    RA2 = RA1 - T1
    Z2 = (RA2 * (IR/100/12))
    T2 = P - Z2
    and so on until NT has reached.
    It should look like
    NT
    P
    Tn
    Zn
    RAn
    1
    372,17
    262,9
    109,27
    22224,83
    2
    372,17
    264,19
    107,98
    21961,93
    3
    372,17
    265,49
    106,68
    21697,74
    4
    372,17
    266,8
    105,38
    21432,25
    5
    372,17
    268,11
    104,06
    21165,45
    6
    372,17
    269,43
    102,75
    20897,34
    7
    372,17
    270,75
    101,42
    20627,91
    8
    372,17
    272,09
    100,09
    20357,16
    9
    372,17
    273,42
    98,75
    20085,07
    10
    372,17
    274,77
    97,41
    19811,65
    11
    372,17
    276,12
    96,06
    19536,88
    12
    372,17
    277,48
    94,7
    19260,76
    13
    372,17
    278,84
    93,33
    18983,28
    14
    372,17
    280,21
    91,96
    18704,44
    15
    372,17
    281,59
    90,59
    18424,23
    16
    372,17
    282,97
    89,2
    18142,64
    17
    372,17
    284,36
    87,81
    17859,67
    18
    372,17
    285,76
    86,41
    17575,31
    19
    372,17
    287,17
    85,01
    17289,55
    20
    372,17
    288,58
    83,59
    17002,38
    21
    372,17
    290
    82,18
    16713,8
    22
    372,17
    291,42
    80,75
    16423,8
    23
    372,17
    292,86
    79,32
    16132,38
    24
    372,17
    294,3
    77,88
    15839,52
    25
    372,17
    295,74
    76,43
    15545,22
    26
    372,17
    297,2
    74,98
    15249,48
    27
    372,17
    298,66
    73,52
    14952,28
    28
    372,17
    300,13
    72,05
    14653,62
    29
    372,17
    301,6
    70,57
    14353,49
    30
    372,17
    303,09
    69,09
    14051,89
    31
    372,17
    304,58
    67,6
    13748,8
    32
    372,17
    306,07
    66,1
    13444,22
    33
    372,17
    307,58
    64,6
    13138,15
    34
    372,17
    309,09
    63,08
    12830,57
    35
    372,17
    310,61
    61,56
    12521,48
    36
    372,17
    312,14
    60,04
    12210,87
    37
    372,17
    313,67
    58,5
    11898,73
    38
    372,17
    315,21
    56,96
    11585,06
    39
    372,17
    316,76
    55,41
    11269,85
    40
    372,17
    318,32
    53,85
    10953,09
    41
    372,17
    319,89
    52,29
    10634,77
    42
    372,17
    321,46
    50,71
    10314,88
    43
    372,17
    323,04
    49,13
    9993,42
    44
    372,17
    324,63
    47,55
    9670,38
    45
    372,17
    326,22
    45,95
    9345,75
    46
    372,17
    327,83
    44,35
    9019,53
    47
    372,17
    329,44
    42,73
    8691,7
    48
    372,17
    331,06
    41,11
    8362,26
    I would appreciate every help and idea to solve the problem solely with sql.
    Thanks and regards
    Carsten

    It's using Model Clause and / or Recursive With (sometimes maybe both)
    Regards
    Etbin
    with
    rec_proc(nt,i,ra,p,ir,z,t) as
    (select nt,i,ra - p,p,ir,round((ra - p) * 0.01 * ir / 12,2),p - round((ra - p) * 0.01 * ir / 12,2)
       from (select 48 nt,22597 ra,372.17 p,5.9 ir,0 z,0 t,1 i
               from dual
    union all
    select nt,i + 1,ra - t,p,ir,round((ra - t) * 0.01 * ir / 12,2),p - round((ra - t) * 0.01 * ir / 12,2)
       from rec_proc
      where i < nt
    select * from rec_proc
    try to adjust initial values and rounding please
    NT
    I
    RA
    P
    IR
    Z
    T
    48
    1
    22224.83
    372.17
    5.9
    109.27
    262.9
    48
    2
    21961.93
    372.17
    5.9
    107.98
    264.19
    48
    3
    21697.74
    372.17
    5.9
    106.68
    265.49
    48
    4
    21432.25
    372.17
    5.9
    105.38
    266.79
    48
    5
    21165.46
    372.17
    5.9
    104.06
    268.11
    48
    6
    20897.35
    372.17
    5.9
    102.75
    269.42
    48
    7
    20627.93
    372.17
    5.9
    101.42
    270.75
    48
    8
    20357.18
    372.17
    5.9
    100.09
    272.08
    48
    9
    20085.1
    372.17
    5.9
    98.75
    273.42
    48
    10
    19811.68
    372.17
    5.9
    97.41
    274.76
    48
    11
    19536.92
    372.17
    5.9
    96.06
    276.11
    48
    12
    19260.81
    372.17
    5.9
    94.7
    277.47
    48
    13
    18983.34
    372.17
    5.9
    93.33
    278.84
    48
    14
    18704.5
    372.17
    5.9
    91.96
    280.21
    48
    15
    18424.29
    372.17
    5.9
    90.59
    281.58
    48
    16
    18142.71
    372.17
    5.9
    89.2
    282.97
    48
    17
    17859.74
    372.17
    5.9
    87.81
    284.36
    48
    18
    17575.38
    372.17
    5.9
    86.41
    285.76
    48
    19
    17289.62
    372.17
    5.9
    85.01
    287.16
    48
    20
    17002.46
    372.17
    5.9
    83.6
    288.57
    48
    21
    16713.89
    372.17
    5.9
    82.18
    289.99
    48
    22
    16423.9
    372.17
    5.9
    80.75
    291.42
    48
    23
    16132.48
    372.17
    5.9
    79.32
    292.85
    48
    24
    15839.63
    372.17
    5.9
    77.88
    294.29
    48
    25
    15545.34
    372.17
    5.9
    76.43
    295.74
    48
    26
    15249.6
    372.17
    5.9
    74.98
    297.19
    48
    27
    14952.41
    372.17
    5.9
    73.52
    298.65
    48
    28
    14653.76
    372.17
    5.9
    72.05
    300.12
    48
    29
    14353.64
    372.17
    5.9
    70.57
    301.6
    48
    30

Maybe you are looking for