2013 Jun 15 12:47 PM
2013 Jun 17 8:06 AM
Hi Ramesh,
You can use text element for that particular window.
You can't use text element the first record will be printed twice.
you can create text element in script,in that window for ex:
/E Te
&FS_EKPO-NETPR&,,&FS_EKPO-MATNR&,,&FS_EKPO-LGORT&,,&FS_EKPO-WEKRS&
call function 'WRITE_FORM'
exporting
ELEMENT = ' TE'
* FUNCTION = 'SET'
* TYPE = 'BODY'
window = 'MAIN'
* 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.
endif.
Answer is correct,please allot me points.
Regards,
Manohar Reddy
2013 Jun 15 1:53 PM
Hi,
Please elaborate with the window code that is doing this. Also my suggestion is to debug your script by Activating debugger in SE71. You can see the line item being processed.
Cheers,
Arindam
2013 Jun 15 2:56 PM
Hi,
The problem may be in the coding I think first line items details are printed correctly.
1.May be you have used the printing variables two times,
2.Inside loop according to some conditions the values will print,condition satisfied in two places or check the IF... ELSE statements used correctly.
Because,If all the conditions failed they will write this item printing conditions in final ELSE part may be your code will satisfies there also.
Go to SE71->Utilities from file menu,Click , Activate debuger and check it or share that overall loop lines of coding.Hope it is useful,Thanks for understanding.
Regards,
Ravi Shankar L
2013 Jun 15 4:07 PM
Debug and check your what data your internal table passing to the Script..
2013 Jun 16 8:20 AM
If its happening only for that order number, probably your internal table is containing duplicate entries. Confirm that that record (order No. 12096) is present only once in your internal table.
2013 Jun 17 4:56 AM
Hi Susmitha,
In my inter table i am not getting any duplicate entries, but in output i am getting duplicate values for first row, I am sharing my code for your reference
*********Declaration part.
tables : kna1.
select-options : s_kunnr for kna1-kunnr.
*******internal table & work area declaration
data : it_kna1 type table of kna1,
wa_kna1 type kna1,
it_vbak type table of vbak,
wa_vbak type vbak.
data : w_tot type vbak-netwr.
*************Start of selection.
start-of-selection.
perform get_kna1_data.
perform get_vbak_data.
***************end of selection.
end-of-selection.
perform start_script.
perform write_to_script.
perform close_script.
*&---------------------------------------------------------------------*
*& Form get_kna1_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_kna1_data .
select * from kna1 into table it_kna1 where kunnr in s_kunnr.
if sy-subrc ne 0.
message 'No Records found for the given selection' type 'I'.
leave list-processing.
endif.
endform. " get_kna1_data
*&---------------------------------------------------------------------*
*& Form get_vbak_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_vbak_data .
select * from vbak into table it_vbak for all entries in it_kna1 where kunnr eq it_kna1-kunnr.
endform. " get_vbak_data
*&---------------------------------------------------------------------*
*& Form start_script
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form start_script .
call function 'OPEN_FORM'
exporting
* APPLICATION = 'TX'
* ARCHIVE_INDEX =
* ARCHIVE_PARAMS =
* DEVICE = 'PRINTER'
* DIALOG = 'X'
form = 'YRAMSCRIPT'
* LANGUAGE = SY-LANGU
* OPTIONS =
* MAIL_SENDER =
* MAIL_RECIPIENT =
* MAIL_APPL_OBJECT =
* RAW_DATA_INTERFACE = '*'
* SPONUMIV =
* IMPORTING
* LANGUAGE =
* NEW_ARCHIVE_PARAMS =
* RESULT =
* EXCEPTIONS
* CANCELED = 1
* DEVICE = 2
* FORM = 3
* OPTIONS = 4
* UNCLOSED = 5
* MAIL_OPTIONS = 6
* ARCHIVE_ERROR = 7
* INVALID_FAX_NUMBER = 8
* MORE_PARAMS_NEEDED_IN_BATCH = 9
* SPOOL_ERROR = 10
* CODEPAGE = 11
* OTHERS = 12
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " start_script
*&---------------------------------------------------------------------*
*& Form write_to_script
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form write_to_script .
clear wa_kna1.
loop at it_kna1 into wa_kna1.
clear w_tot.
call function 'START_FORM'
exporting
* ARCHIVE_INDEX =
form = 'YRAMSCRIPT'
* LANGUAGE = ' '
* STARTPAGE = ' '
* PROGRAM = ' '
* MAIL_APPL_OBJECT =
* IMPORTING
* LANGUAGE =
* EXCEPTIONS
* FORM = 1
* FORMAT = 2
* UNENDED = 3
* UNOPENED = 4
* UNUSED = 5
* SPOOL_ERROR = 6
* CODEPAGE = 7
* OTHERS = 8
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'WRITE_FORM'
exporting
* ELEMENT = ' '
* FUNCTION = 'SET'
* TYPE = 'BODY'
window = 'ADDRESS'
* 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.
endif.
loop at it_vbak into wa_vbak where kunnr eq wa_kna1-kunnr.
w_tot = w_tot + wa_vbak-netwr.
call function 'WRITE_FORM'
exporting
* ELEMENT = ' '
* FUNCTION = 'SET'
* TYPE = 'BODY'
window = 'MAIN'
* 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.
endif.
endloop.
call function 'END_FORM'
* IMPORTING
* RESULT =
* EXCEPTIONS
* UNOPENED = 1
* BAD_PAGEFORMAT_FOR_PRINT = 2
* SPOOL_ERROR = 3
* CODEPAGE = 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.
endloop.
endform. " write_to_script
*&---------------------------------------------------------------------*
*& Form close_script
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form close_script .
call function 'CLOSE_FORM'
* IMPORTING
* RESULT =
* RDI_RESULT =
* TABLES
* OTFDATA =
* EXCEPTIONS
* UNOPENED = 1
* BAD_PAGEFORMAT_FOR_PRINT = 2
* SEND_ERROR = 3
* SPOOL_ERROR = 4
* CODEPAGE = 5
* OTHERS = 6
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " close_script
Regards,
Ramesh.T
2013 Jun 17 5:08 AM
Hi,
Please use debug option for sapscript to understand your code. Use program RSTXDBUG or u have option in utilities - activate debugger.
Cheers,
Arindam
2013 Jun 17 5:46 AM
Try clearing all work areas
*----------------------------------------------------------------------*
form write_to_script .
clear : wa_kna1, wa_vbak.
2013 Jun 17 5:53 AM
Can you show a screen shot of your script editor also?
I still have the feeling that there are two entries in the vbak table for the same sold to party (Kunnr) with the same order number (aufnr)
Insert this statement.
sort i_vbak by kunnr aufnr.
Then debug at this point to see the entries in i_vbak.
(And if there are more than one entries and it is not desirable to output them you can use the following statement after the sort statement.
delete adjacent duplicates from i_vbak. )
2013 Jun 17 6:39 AM
2013 Jun 17 6:41 AM
2013 Jun 17 6:55 AM
So just clear WA_VBAK after print.
beyond this you have nothing to do anything.
2013 Jun 17 6:59 AM
Hi,
clearing wa_vbak should solve the issue. Is this code written only in this window or in any other window.
Regards,
Swarna
2013 Jun 17 5:26 AM
Hi,
your internal table contains duplicate values.
You can use
1) sort <internal table>
then
2) delete adjacent duplicate from <internal table>
then after pass to script.
Regards
Avirat Patel
2013 Jun 17 5:32 AM
Hi Aviral,
I checked internal table there is no duplicate values in it.
2013 Jun 17 5:41 AM
Hi,
Clearing your work area wa_vbak,w_tot should help.
Cheers,
Arindam
2013 Jun 17 7:40 AM
Hi ramesh,
Try to clear all the Work areas used, sort and delete the adjacent duplicates of an itab then check.
Regards,
Satish.
2013 Jun 17 8:06 AM
Hi Ramesh,
You can use text element for that particular window.
You can't use text element the first record will be printed twice.
you can create text element in script,in that window for ex:
/E Te
&FS_EKPO-NETPR&,,&FS_EKPO-MATNR&,,&FS_EKPO-LGORT&,,&FS_EKPO-WEKRS&
call function 'WRITE_FORM'
exporting
ELEMENT = ' TE'
* FUNCTION = 'SET'
* TYPE = 'BODY'
window = 'MAIN'
* 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.
endif.
Answer is correct,please allot me points.
Regards,
Manohar Reddy
2013 Jun 17 10:34 AM
Hi Manohar,
Your answer is correct, now it is working.
Good, keep it up.
Thank You,
Ramesh.T
2013 Jun 17 11:00 AM
Dear Manohar,
Can you explain, we we need to use this element in scripts, what is its use.
Regards,
Ramesh.T
2013 Jun 17 11:24 AM
Hi Ramesh,
Explanation about Text element:-
Text Element:
Text element is the name given to the black of elements in the page window. The text element name is followed by /E.
If we pass text element name in the WRITE_FORM function module then WRITE_FORM transfers the data from driver program to all the statements which are defined under text element.
2013 Jun 17 11:37 AM
Hi Ramesh,
The /E in the tag column is used to identify the text as a text element Windows
2013 Jun 17 11:43 AM
2013 Jun 17 10:26 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |