2006 Jun 27 11:47 AM
Hi All.
I modified a standard Form(RVORDER01) according to our format, in that I want to do some calculations ( Ex. Amount = Quantity(vbdpa-kwmeng) * Rate(vbdpa-netpr) ) like this.
2..Is it possible to declare some variables in Form. How?
3..I want to display Amount also as one column & last I want to display Sum of all that amount. How can I calculate the sum.
Any one can help me ASAP
Regards
Rajendra
Hi All.
I modified a standard Form(RVORDER01) according to our format, in that I want to do some calculations ( Ex. Amount = Quantity(vbdpa-kwmeng) * Rate(vbdpa-netpr) ) like this.
2..Is it possible to declare some variables in Form. How?
3..I want to display Amount also as one column & last I want to display Sum of all that amount. How can I calculate the sum.
Any one can help me ASAP
Regards
Rajendra
2006 Jun 27 11:49 AM
if u taking about sap script than u can't...
but u use perform statement to ful:fill ur requirment without changing standared driver programm.
<b>ex---</b>
PERFORM get_date IN PROGRAM zreport
/:USING &SALESORDER&
/:CHANGING &S_DATE&
/:ENDPERFORM
Now you can print S_DATE.
Write this code in the new ABAP program would be
REPORT zreport.
FORM get_date TABLES in_tab STRUCTURE ITCSY
out_tab STRUCTURE ITCSY .
READ TABLE in_tab INDEX 1.
SELECT some_date FROM ztab
WHERE salesorder = in_tab-value.
IF sy-subrc EQ 0.
READ TABLE out-tab INDEX 1.
MOVE ztab-somedate TO out_tab-value
MODIFY out_tab INDEX 1.
ENDIF.
ENDFORM.
2006 Jun 27 12:14 PM
Hi All..
I am not changing any thing in the print program(RVADOR01). Just I am changing the Form(RVORDER01). I am using the same fields in the Form only.. but I want to do above calculations in the form. How can I add it?
Regards
Rajendra
2006 Jun 27 11:51 AM
YOu can use the keyword DEFINE to declare your variables:
sample:
/: DEFINE &BARCODE& := '&SPACE(12)&'
/* DEFINE &BARCV& := '&KARTE-BARCV&' (REMOVED FOR INUSE BARCODE)
/: DEFINE &BARC6& := '&KARTE-BARC6&'
/: PERFORM GET_BARCODE6 IN PROGRAM ZVXR0076
/* USING &BARCV&
/: USING &BARC6&
/: CHANGING &BARCODE&
/: ENDPERFORM
Code in the se38 program for ZVXR0076
FORM get_barcode TABLES sap_data STRUCTURE itcsy
abap_data STRUCTURE itcsy.
DATA : barcv LIKE karte-barcv,
barcode(11).
READ TABLE sap_data WITH KEY name = 'BARCV'.
IF sy-subrc EQ 0.
MOVE sap_data-value TO barcv.
ENDIF.
WRITE barcv TO barcode NO-ZERO.
CONDENSE barcode NO-GAPS.
READ TABLE abap_data WITH KEY name = 'BARCODE'.
IF sy-subrc EQ 0.
abap_data-value = barcode.
MODIFY abap_data INDEX sy-tabix.
ENDIF.
ENDFORM. "GET_BARCODE
REgards,
ravi
2006 Jun 27 11:53 AM
Hi Rajendra,
2.Is it possible to declare some variables in Form. How?
You cannot declare your variable in the form.You have to declare your variable in the print program.
3.I want to display Amount also as one column & last I want to display Sum of all that amount. How can I calculate the sum.
add one more field 'AMOUNT' in your internal table in the print program and in the layout of the form.
Loop at int_tab.
sum = sum+amount.
endloop.
calculate sum and add a window for displaying sum in your form and populate this variable for sum.
2006 Jun 27 11:59 AM
Hi Rajendra,
I suppose you are talking abt Smartforms.
1) You can perform the above-said calculation by using a "Program lines" node. Right click in any window, you can go to "create"option. In that there is option for program lines. In that you can perform your calculation.
2)You can declare variables in Forms in the Global Definition section of the form.
3)You can use template and loop for displaying the table content. Then in the loop, create the program lines, in which you keep on adding the amount values to a sum variable.Make sure you fill the INput and output parameters:
for eg: if sum = sum + val.
then input parameters should be sum,val and output parameter should be sum.
Finally for printing the sum alone, you can create a template and adjust the template so as to fit in the table format and display the sum value.
Hope my point is clear.
Regards,
SP.
2006 Jun 27 12:59 PM
Hi Rajendra,
1. Do all your calculations in the driver program and assign it to a variable. Display this variable in the script.
<b>loop at i_tab.
ws_total = ws_total + i_tab-netpr.
endloop.</b>
Display the variable in the script like
<b>&ws_total&</b>
2. No it is not possible to declare the variables in the script. It is possible to assign values to declared variables like
<b>/: DEFINE &ws_variable& = 'Test'.</b>
3. Do the display part for all the line items in a loop like, but create text elements to display each line item and then then total separately.
<b> ws_element_name = ws_tm01.
ws_window_name = ws_main.
LOOP AT i_lines1.
PERFORM write_form1 USING ws_element_name
ws_window_name.
ENDLOOP.</b>
After that display the total value
ws_element_name = ws_tm07.
ws_window_name = ws_main.
PERFORM write_form USING ws_element_name ws_window_name.
&----
*& Form write_form
&----
text
----
--> p1 text
<-- p2 text
----
FORM write_form USING p_element_name p_window_name.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = p_element_name
FUNCTION = 'SET'
type = 'BODY'
window = p_window_name
IMPORTING
PENDING_LINES =
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
OTHERS = 10
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
MESSAGE e004(zswqc).
ENDIF.
ENDFORM. " write_form
Hope this solves ur issue. Reward if helpful.
Regards,
Tushar