Urgent : - WRITE_FORM & sy-subrc eq 8
Hi Experts,
While using WRITE_FORM for SAP SCRIPT
call function 'WRITE_FORM'
exporting
element = 'DESTI'
window = 'DEST'
exceptions
window = 6
others = 8.
This FM is giving me Sy-subrc value 8.
What really the value of sy-subrc eq 8 refers.???
Any inputs on this will be rewarded.
Rgds ~ Lakshmiraj
Hi,
Thanks a lot....
I followed your step....Still the same ERROR is COMING
I tried to change this as u suggested also...
*CALL FUNCTION 'WRITE_FORM'*
*EXPORTING*
*ELEMENT = 'DESTI'*
*FUNCTION = 'SET'*
*TYPE = 'BODY'*
*WINDOW = 'DEST'.*
** EXCEPTIONS*
** WINDOW = 6*
** OTHERS = 8.*
Pls find the code below
REPORT Z_LAY_BILL LINE-COUNT 65 NO STANDARD PAGE HEADING.
TABLES : J_1IEXCHDR,J_1IEXCDTL,J_1IMOCOMP,J_1IMOCUST,LIKP,VBKD,VBAK,VBRK
,KNA1,T001W,VBRP,VBFA,TVTWT,TSPAT,TVKOT,MAKT,BSEG,T052U,KONV,
T685T.
PARAMETER : EXNUM2 LIKE J_1IEXCHDR-EXNUM.
DATA : HRFW LIKE SPELL,
MINFW LIKE SPELL,
HRTW LIKE SPELL,
MINTW LIKE SPELL,
SPELL LIKE SPELL,
* HR1 LIKE BSEG-DMBTR,
* HR2 LIKE BSEG-DMBTR,
* MIN1 LIKE BSEG-DMBTR,
* MIN2 LIKE BSEG-DMBTR.
HR1(2),
HR2(2),
MIN1(2),
MIN2(2).
CALL FUNCTION 'OPEN_FORM'
EXPORTING
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = 'Z_LAY_INVOICE'
LANGUAGE = SY-LANGU
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
OTHERS = 10.
*CALL FUNCTION 'START_FORM'*
*EXPORTING*
** ARCHIVE_INDEX =*
*FORM = 'Z_LAY_INVOICE'*
*LANGUAGE = SY-LANGU*
*STARTPAGE = 'FIRST'*
** PROGRAM = ' '*
** MAIL_APPL_OBJECT =*
** IMPORTING*
** LANGUAGE =*
** EXCEPTIONS*
** FORM = 1*
** FORMAT = 2*
** UNENDED = 3*
** UNOPENED = 4*
** UNUSED = 5*
** SPOOL_ERROR = 6*
** OTHERS = 7*
*IF SY-SUBRC <> 0.*
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.*
*ENDIF.*
SELECT * FROM J_1IEXCHDR WHERE EXNUM = EXNUM2.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'EXNUM'
WINDOW = 'INV_NUM'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
SELECT * FROM J_1IEXCDTL WHERE EXNUM = J_1IEXCHDR-EXNUM
AND DOCNO = J_1IEXCHDR-DOCNO
AND EXDAT = J_1IEXCHDR-EXDAT.
SELECT SINGLE * FROM J_1IMOCOMP WHERE BUKRS = J_1IEXCHDR-BUKRS
AND WERKS = J_1IEXCHDR-WERKS.
SELECT SINGLE * FROM VBRP WHERE VBELN = J_1IEXCHDR-RDOC.
SELECT SINGLE * FROM VBAK WHERE VBELN = VBRP-VGBEL.
SELECT SINGLE * FROM VBKD WHERE VBELN = VBAK-VBELN.
SELECT SINGLE * FROM VBRK WHERE VBELN = VBRP-VBELN.
SELECT SINGLE * FROM LIKP WHERE VBELN = VBRP-VGBEL.
SELECT SINGLE * FROM J_1IMOCUST WHERE KUNNR = VBRK-KUNRG.
SELECT SINGLE * FROM TVTWT WHERE VTWEG = VBAK-VTWEG
AND SPRAS = SY-LANGU.
SELECT SINGLE * FROM TSPAT WHERE SPART = VBAK-SPART
AND SPRAS = SY-LANGU.
SELECT SINGLE * FROM TVKOT WHERE VKORG = VBAK-VKORG
AND SPRAS = SY-LANGU.
SELECT SINGLE * FROM T001W WHERE WERKS = J_1IEXCHDR-WERKS.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'DIVISION'
WINDOW = 'DIV'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'PLANTNAME'
WINDOW = 'PLANT'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CUSTORD'
WINDOW = 'CORD'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'INVOICE'
WINDOW = 'INVO'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TARRIF'
WINDOW = 'TARIF'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
DATA : X TYPE T.
X = J_1IEXCDTL-CPUTM + 900.
HR1 = J_1IEXCDTL-CPUTM+0(2).
HR2 = X+0(2).
MIN1 = J_1IEXCDTL-CPUTM+2(2).
MIN2 = X+2(2).
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
LANGUAGE = SY-LANGU
* currency = 'INR'
AMOUNT = HR1 " J_1IEXCHDR-CPUTM
IMPORTING
IN_WORDS = SPELL.
CONCATENATE SPELL-WORD ' Hour(s) ' INTO HRFW.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
LANGUAGE = SY-LANGU
* currency = 'INR'
AMOUNT = MIN1 " J_1IEXCHDR-CPUTM
IMPORTING
IN_WORDS = SPELL.
CONCATENATE SPELL-WORD ' Min(s) ' INTO MINFW.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
LANGUAGE = SY-LANGU
* currency = 'INR'
AMOUNT = HR2 " J_1IEXCHDR-CPUTM
IMPORTING
IN_WORDS = SPELL.
CONCATENATE SPELL-WORD ' Hour(s) ' INTO HRTW.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
LANGUAGE = SY-LANGU
* currency = 'INR'
AMOUNT = MIN2 " J_1IEXCHDR-CPUTM
IMPORTING
IN_WORDS = SPELL.
CONCATENATE SPELL-WORD ' Min(s) ' INTO MINTW.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'EXCODED'
WINDOW = 'EXCODE'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
SELECT SINGLE * FROM KNA1 WHERE KUNNR = VBRK-KUNRG.
SELECT SINGLE * FROM J_1IMOCUST WHERE KUNNR = VBRK-KUNRG.
DATA : P_NAME LIKE THEAD-TDNAME.
CONCATENATE VBRK-VBELN VBRP-POSNR INTO P_NAME.
DATA : BEGIN OF TEXT2 OCCURS 0.
INCLUDE STRUCTURE TLINE.
DATA : END OF TEXT2.
CALL FUNCTION 'READ_TEXT'
EXPORTING
ID = '0002'
LANGUAGE = SY-LANGU
NAME = P_NAME
OBJECT = 'VBBP'
TABLES
LINES = TEXT2
EXCEPTIONS
NOT_FOUND = 4
OBJECT = 5
OTHERS = 8.
LOOP AT TEXT2.
* write :/ text2-tdline.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'DESC'
WINDOW = 'MAIN'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
ENDLOOP.
PERFORM SKIPPING.
DATA : TAX(3),
TAX1(10),
TAXAMT LIKE KONV-KWERT,
CENTAX LIKE BSEG-DMBTR,
ECSTAX LIKE BSEG-DMBTR,
CENTEXT(50).
SELECT * FROM KONV WHERE KNUMV = VBRK-KNUMV AND
KWERT NE 0
AND KSCHL NE 'ZD00'.
SELECT SINGLE * FROM T685T WHERE KSCHL = KONV-KSCHL
AND SPRAS = SY-LANGU
AND KAPPL = 'V'.
* WRITE :/ konv-kschl,T685T-VTEXT,KONV-KWERT.
TAX = KONV-KBETR / 10.
IF KONV-KSCHL = 'JMOD'.
TAX1 = KONV-KBETR / 10.
CONTINUE.
ELSEIF KONV-KSCHL = 'JEX2'.
SELECT SINGLE * FROM KONV WHERE KNUMV = VBRK-KNUMV AND
KWERT NE 0
AND KSCHL = 'JMOD'.
TAX = KONV-KBETR / 10.
CENTAX = KONV-KWERT.
ENDIF.
IF KONV-KSCHL = 'JECS'.
TAX1 = '2'.
CONTINUE.
ELSEIF KONV-KSCHL = 'JECX'.
SELECT SINGLE * FROM KONV WHERE KNUMV = VBRK-KNUMV AND
KWERT NE 0
AND KSCHL = 'JECS'.
TAX = '2'.
ECSTAX = KONV-KWERT.
ENDIF.
TAXAMT = TAXAMT + KONV-KWERT.
TAX1 = KONV-KAWRT.
IF KONV-WAERS = 'INR'.
CONCATENATE T685T-VTEXT '' INTO CENTEXT.
ELSE.
CONCATENATE T685T-VTEXT '@ ' TAX '%' INTO CENTEXT.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TAX'
WINDOW = 'MAIN'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
CLEAR: TAX,CENTEXT.
ENDSELECT.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CUSTNAME'
WINDOW = 'CUSTOMER'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CSTNOL'
WINDOW = 'CST'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
*CALL FUNCTION 'WRITE_FORM'*
*EXPORTING*
*ELEMENT = 'DESTI'*
*FUNCTION = 'SET'*
*TYPE = 'BODY'*
*WINDOW = 'DEST'.*
** EXCEPTIONS*
** WINDOW = 6*
** OTHERS = 8.*
DATA: NET LIKE VBRP-BRGEW.
NET = VBRP-BRGEW - VBRP-NTGEW.
SELECT SINGLE * FROM T052U WHERE ZTERM = VBRK-ZTERM.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TERM'
WINDOW = 'TERMS'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TRANS'
WINDOW = 'TRANSP'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'KILO'
WINDOW = 'KG'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
DATA : NET1 LIKE VBRP-BRGEW.
SELECT SINGLE * FROM KONV WHERE KNUMV = VBRK-KNUMV AND
KSCHL = 'ZD00'.
NET1 = KONV-KBETR.
VBRP-NETWR = KONV-KWERT.
* net1 = vbrp-netwr / vbrp-fkimg.
SELECT SINGLE * FROM MAKT WHERE MATNR = VBRP-MATNR.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'MATERIAL'
WINDOW = 'MATDET'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
DATA: AMTINWORDS LIKE SPELL.
DATA : CENAMT LIKE SPELL.
DATA : ECSAMT LIKE SPELL.
DATA : AMT LIKE BSEG-DMBTR.
AMT = VBRP-NETWR + TAXAMT.
CALL FUNCTION 'ZSPELL_AMOUNT'
EXPORTING
NUMBER = AMT
IMPORTING
NUM_WORDS = AMTINWORDS
EXCEPTIONS
OTHERS = 1.
DATA : L TYPE I,
L1 TYPE I,
AMTINWORDS1(80),
AMTINWORDS2(80),
CENAMT1(80),
CENAMT2(80),
ECSAMT1(80),
ECSAMT2(80).
AMTINWORDS1 = AMTINWORDS.
L = STRLEN( AMTINWORDS ).
IF L > 80.
AMTINWORDS1 = AMTINWORDS+0(79).
AMTINWORDS2 = AMTINWORDS+80(79).
ENDIF.
CALL FUNCTION 'ZSPELL_AMOUNT'
EXPORTING
NUMBER = CENTAX
IMPORTING
NUM_WORDS = CENAMT
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC EQ 0.
L1 = STRLEN( CENAMT ).
CENAMT1 = CENAMT+0(79).
IF L > 80.
CENAMT1 = CENAMT+0(79).
CENAMT2 = CENAMT+80(79).
ENDIF.
ENDIF.
CALL FUNCTION 'ZSPELL_AMOUNT'
EXPORTING
NUMBER = ECSTAX
IMPORTING
NUM_WORDS = ECSAMT
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC EQ 0.
L1 = STRLEN( ECSAMT ).
ECSAMT1 = ECSAMT+0(79).
IF L > 80.
ECSAMT1 = ECSAMT+0(79).
ECSAMT2 = ECSAMT+80(79).
ENDIF.
ENDIF.
IF CENTAX NE 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CENT'
WINDOW = 'CENT'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'END1'
WINDOW = 'END'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'AMT1'
WINDOW = 'AMT'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
ENDSELECT.
ENDSELECT.
*CALL FUNCTION 'END_FORM'*
** IMPORTING*
** RESULT =*
** EXCEPTIONS*
** UNOPENED = 1*
** BAD_PAGEFORMAT_FOR_PRINT = 2*
** SPOOL_ERROR = 3*
** OTHERS = 4*
*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 'CLOSE_FORM'
EXCEPTIONS
UNOPENED = 1
OTHERS = 4.
* FORM SKIPPING *
FORM SKIPPING.
DO 6 TIMES.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'SKIPP'
WINDOW = 'MAIN'
EXCEPTIONS
WINDOW = 6
OTHERS = 8.
ENDDO.
ENDFORM.
Pls help
Similar Messages
-
Script: Sub totals & Grand Totals.(Urgent)
Hi Gurus
im developing a invoice billing. for this i need hw to get sub totals and grand totals at the last page in my main window . what should be given in the text elements and in the SE 38 part.please help me with this its very urgent.
correct answers are fully rewarded.
thanks in advance.
thanks & regards.
sirish.If you want your totals in fixed place than you need to create a new window and element inside it.
If you want just after the finishing of the main data than you can create a element in MAIN window and call it with the call FM WRITE_FORM.
Here is the small example:
DATA: W_SUM TYPE VBRP-NETWR.
START-OF-SELECTION.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = 'ZTEST_NP'
LANGUAGE = SY-LANGU.
DO 3 TIMES.
W_SUM = W_SUM + SY-INDEX. " << sum
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAIN'
WINDOW = 'MAIN'.
ENDDO.
* Fixed window for SUM
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'LAST'
WINDOW = 'LAST'.
IF SY-SUBRC <> 0.
ENDIF.
CALL FUNCTION 'CLOSE_FORM'
Regards,
Naimesh Patel -
Logical command in ABAP.....Urgent
Hi,
i am pretty new using ABAP program so i neeed help urgently. i am trying to move a file on the application server from one directory to the other and i was using the open dataset function to do that. but the file i am trying to move is pretty big and because i am using internal table to store, it is causing problems with the space.
i have consulted the basis guys and they have managed to create a logical file for copying from one directory to the other on the application server. to help you furthter. i am enclosing the mail sent to me.
I have created a logical command which should copy the file from one location to the other but you need to pass it the source dir and file name and the destination dir and file name.
The logical command is ZCOPY and uses cmd /c copy
Copies one or more files to another location.
COPY [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
[+ source [/A | /B] [+ ...]] [destination [/A | /B]]
source Specifies the file or files to be copied.
/A Indicates an ASCII text file.
/B Indicates a binary file.
destination Specifies the directory and/or filename for the new file(s).
/V Verifies that new files are written correctly.
/N Uses short filename, if available, when copying a file with a
non-8dot3 name.
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.
The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line. Default is
to prompt on overwrites unless COPY command is being executed from
within a batch script.
the problem now is i have no idea about how to use the logical command. can any one help me.
Thank you,
Ravi.If memory is not an issue, then there should be no reason why this should not work.
report zrich_0001.
parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt',
d2 type localfile default '/usr/sap/TST/SYS/Data2.txt'.
data: itab type table of string with header line.
start-of-selection.
* Read old file
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into itab.
if sy-subrc <> 0.
exit.
endif.
append itab.
enddo.
endif.
close dataset d1.
* Write to new file
open dataset d2 for output in text mode.
loop at itab.
transfer itab to d2.
endloop.
close dataset d2.
* Delete the old file
delete dataset d1.
Regards,
Rich Heilman -
Update Routine ... Help me Please--VERY URGENT
Hi All ,
I Moving data from Cube to ODS . Let me explain abt the records in the cube .
There are 6 key figures in the cube as well as dimensions, UNIQKEY TRANSACTION is One Dimension and ARTICLE is another dimension which is having an Navigational attribute called CORE ELEMENT.
I am showing the data with those two dimension and the key figures which are to be used in the routine.
Charc----
Key Figures
UNIQKEY-ARTICLE-Coreelement--
billqty
in base unit
A00N----1006330--1--
10.5
A00M -
1006320----2--
2.5
A00P-----1006330--1--
10.5
A00P-----1006320--2--
2.5
A00Q-----1006320--2--
2.5
A00Q-----1006340--3--
10.5
Now Lets see what the core element numbers mean,
core element 1 means -- fuel .
Core elemnet other 1 -- food .
I need to move these data into ODS Which will have an extra field called No of items in the transaction --ITEMS.For this i need to write a routine .
The Logic is ...
1.if Materail is of type 1(Means if the core element - 1)
I need to Populate the No of items in tnx = 1 .--ITEMS.
2.If Material is of type(Means if the core element)2or 3 I need to populate the billing quantity to the no of transcations.--ITEMS
3. If the Uniqkey tanscation contains two line items as suppose that you have 20 litres of fuel and 2 cans of coke, then No of Items in the transaction should be 3 and Billing Quantity in BUoM 22
billing quantity in BUoM = 20 litres for the first line item and 2 for the second line item...
then as the first line item is fuel, field No OF Items in the Transcation should be 1 (replacing the 20) + 2 = 3
so the final result in the ODS should be billing quantity in BUoM = 22 and The Items in the Transcation= 3
So the ODS Data should look like this.
UNIQKEY--billqty--
ITEMS
in base unit
A00N--10.5--
1
A00M--2.5--
2.5
A00P--13--
3.5
A00Q--13--
12.5
NOTE : IN the ODS only the UNIQKEY IS THE KEY FIELD and the rest are DATA FIELDS.
I Posted this one before also. But didnt get proper responses.
I am Pasting the piece of code which I have written . This code will work for the first two records in the cube , But it is failing for the UNIQKEY Transcation having Line items.
PROGRAM UPDATE_ROUTINE.
$$ begin of global - insert your declaration only below this line -
TABLES: /BI0/PMATERIAL.
DATA: TITEMS LIKE /BIC/AZPOCODS00-/BIC/ZTITEMS,
CORE_ELEMENT like /BI0/PMATERIAL-RPA_WGH1.
$$ end of global - insert your declaration only before this line -
FORM compute_data_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
USING COMM_STRUCTURE LIKE /BIC/CS8ZPOCTUS04
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING RESULT LIKE /BIC/AZPOCODS00-/BIC/ZTITEMS
RETURNCODE LIKE SY-SUBRC "Do not use!
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
$$ begin of routine - insert your code only below this line -
fill the internal table "MONITOR", to make monitor entries
check not COMM_STRUCTURE-material is initial.
select SINGLE RPA_WGH1
INTO CORE_ELEMENT
from /BI0/PMATERIAL
where
material = COMM_STRUCTURE-material
and OBJVERS <>'D'.
IF CORE_ELEMENT EQ '1'.
TITEMS = '1'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = titems
IMPORTING
OUTPUT = titems
ELSE.
TITEMS = COMM_STRUCTURE-BILL_QTY.
ENDIF.
result value of the routine
RESULT = TITEMS..
if abort is not equal zero, the update process will be canceled
ABORT = 0.
$$ end of routine - insert your code only before this line -
PLease give me ideas on how to acheive this . As I am not Aware of ABAP very well.. PLease try to give me the code. I hope one of you may got the same requirement before.
Its very urgent and I need to deliver it today itself.
Thanks in advance , you can mail me to [email protected]. If anybody intersted to discuss this Issue they can reach at +91 9845922955.Hi ,
While I am moving the data from cube to ods . I need to create the update rules with cube -- 8cube . WHen i am doing this the billqty is a key figure in cube so that is not a problem but the ITEMS is not there in the cube ,SO for that I need to write a routine to populate that one.
Its strange but the user what to analyse with the UNIQKEY transaction. And these objects will be added as navigational attributes to the Characteristic. as it acts as another dimension.
He wants to laod these from ODS to Master data -Characteristic.
to say for each transcation hpw many items are getting sold.
Message was edited by: Nagarjuna Reddy
ONce again thanks for the qucik replies
Message was edited by: Nagarjuna Reddy -
UPDATE ROUTINE --- CUBE --- ODS Very Very URGENT
Hi Collegues/Friends ,
First I need to thank for the intiators of this site , as I came to know that for many
problems we will get different best solutions ... Hoping the same I am posting a question
which is very very very urgent as the client is running after me for this .
My Requirement is as Follows. ..
I Moving the data from Cube to ODS . While i need to write a routine for an extra field in
ODS based on Billing Quantity in Base Unit of Measure . The Key Field in the ODS Is UNIQKEY
Transaction and It is a Characterstic in the Cube and we have MAterial as another
Characteristic and core element as navigational attribute .
In the Cube for every UNIQKEY transaction- there are more than One line items.
My data fields in the ODS are Billing Quantity in Base Unit of MEasure and and EXTRA FIELD
: No of Items in Transaction . But the thing is that I have only Billing Quantity in Base
Unit of Measure in cube as a key figure
BAsing on the UNIQKEY transcation and Billing Quantity In Base Unit Of Measure I need to
populate the No of Items in Transaction... For this i need to write a routine .
Let suppose say that for the Materials the core elements are as follows
Material Core element
10 1 -- fuel -- In liters
20 2 -- Cigar - in PAck
30 3 -- Coke - in Cans
Now Lets see how the records are there in InfoCUbe
Uniqkey / Material / Core element /Billin Quantiy
A / 10 / 1 / 22
B / 30 / 3 / 2
C / 10 / 1 / 15
C / 30 / 3 / 2
D / 20 / 2 / 10
D / 30 / 3 / 2
And IN the ODS -- I need to Populate the No OF items in Transaction.
the Logic behind this as follows .
1.if Materail is of type 1(Mean if the core element - 1)
I need to Populate the No of items in tnx = 1
2.If Material id of type 2 or 3 I need to populate the billing quantity to the no of
transcations.
3. If the Uniqkey tanscation contains two line items as suppose that you have 20 litres of
fuel and 2 cans of coke, then No of Items in the transaction should be 3 and Billing
Quantity in BUoM 22
billing quantity in BUoM = 20 litres for the first line item and 2 for the second line
item...
then as the first line item is fuel, field No OF Items in the Transcation should be 1
(replacing the 20) + 2 = 3
so the final result in the ODS should be billing quantity in BUoM = 22 and The Items in the
Transcation = 3
For this I have Written a Rouinte like this for that field
PROGRAM UPDATE_ROUTINE.
$$ begin of global - insert your declaration only below this line -
TABLES: /BI0/PMATERIAL.
DATA: TITEMS LIKE /BIC/AZPOCODS00-/BIC/ZTITEMS,
CORE_ELEMENT like /BI0/PMATERIAL-RPA_WGH1.
$$ end of global - insert your declaration only before this line -
FORM compute_data_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
USING COMM_STRUCTURE LIKE /BIC/CS8ZPOCTUS04
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING RESULT LIKE /BIC/AZPOCODS00-/BIC/ZTITEMS
RETURNCODE LIKE SY-SUBRC "Do not use!
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
$$ begin of routine - insert your code only below this line -
fill the internal table "MONITOR", to make monitor entries
check not COMM_STRUCTURE-material is initial.
select SINGLE RPA_WGH1
INTO CORE_ELEMENT
from /BI0/PMATERIAL
where
material = COMM_STRUCTURE-material
and OBJVERS <>'D'.
IF CORE_ELEMENT EQ '1'.
TITEMS = '1'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = titems
IMPORTING
OUTPUT = titems
ELSE.
TITEMS = COMM_STRUCTURE-BILL_QTY.
ENDIF.
result value of the routine
RESULT = TITEMS..
if abort is not equal zero, the update process will be canceled
ABORT = 0.
$$ end of routine - insert your code only before this line -
Does it satisfy all the conditions ?? mentioned above if . As far As i know as the only key
field in the transcation it will satisfy the first two conditions .
I want to know or If possioble anybody pls take some pain for me to send the code or any
Ideas for satisfying all the conditions.
Hope I will get immediate replies....
Mail me to [email protected]Reddy,
Please do not post in all sections ... makes it hard to follow up on posts..
Arun -
V V URGENT Report for Vendor Aging
Hi ABAP Gurus,
I have to develop a report for VENDOR AGING. My requirement is i have to post an invoice. From Payment terms i have to get Dependent on posting date. Let us assume if payment term is 100 by adding posting date + payment term (100) i have to get due date. I'am giving I/P terms as Company code & Period. If i enter company code i have to get O/P as vendor name(lfa1-name1),vendor no(bsik-lifnr),bill no(bsik-xblnr),bill date(bsik-bldat) i.e., baseline date,amount(bsik-dmbtr) and duedate (this i have to pick from payment terms). For period i have to get O/P as 1st week bucket,2nd week bucket,3rd week bucket,4th week bucket and beyond. For this you have to take the difference b/n due date and that buckets based on this result you have to put that amount of rupees whether it is going to pay in 1st week r 2nd r 3rd r 4th or beyond this. If that due date is less than or equal to 1st week it has to come and fall in 1st week. THIS IS MY REQUIREMENT.
For this i'am using tables BSIK,LFA1.
Can any body send me the code on this. For this my delivery date is on monday.
Please help me on this it's very Urgent...
I will REWARD you the points definitely for those who help me on this.
my mail id : [email protected]
waiting for your VALUABLE REPLIES. Please intimate me if you send it to my mail.
Thanks and Regards,
Sundeep.Hi
See the report code and modify as per your requirements
REPORT zfi_vendor_ageing
NO STANDARD PAGE HEADING
LINE-COUNT 58
line-size 168
MESSAGE-ID zh_msg.
D A T A B A S E T A B L E S D E C L A R A T I O N
TABLES: lfa1, " Vendor Master (General)
t001, " Company Codes
rfpdo.
I N T E R N A L T A B L E S D E C L A R A T I O N S *
Internal Table for Vendor Open Items Data
DATA: BEGIN OF int_bsik OCCURS 0,
lifnr LIKE bsik-lifnr, " Vendor Number
name1 LIKE lfa1-name1, " Vendor Name
shkzg LIKE bsik-shkzg, " Dr/Cr Indicator
belnr LIKE bsik-belnr, " Document Number
xblnr LIKE bsik-xblnr, " Ref Doc No
blart LIKE bsik-blart, " Document Type
zfbdt LIKE bsik-zfbdt, " Base Line Date
zbd1t LIKE bsik-zbd1t, " Due date1
zbd2t LIKE bsik-zbd2t, " Due Date2
zbd3t LIKE bsik-zbd3t, " Due Date3
waers LIKE bsik-waers, " Currency
dmbtr LIKE bsik-dmbtr, " Amount in Local Curr
END OF int_bsik.
Internal Table for Amounts Sum Up Data
DATA: BEGIN OF int_final OCCURS 0,
lifnr LIKE bsik-lifnr, " Vendor Number
name1 LIKE lfa1-name1, " Vendor Name
total1 LIKE bsik-dmbtr, " Amount in Local Curr
total2 LIKE bsik-dmbtr, " Amount in Local Curr
total3 LIKE bsik-dmbtr, " Amount in Local Curr
total4 LIKE bsik-dmbtr, " Amount in Local Curr
total5 LIKE bsik-dmbtr, " Amount in Local Curr
total6 LIKE bsik-dmbtr, " Amount in Local Curr
total LIKE bsik-dmbtr, " Amount in Local Curr
END OF int_final.
D A T A D E C L A R A T I O N S
DATA : v_flag, " Flag
v_gtotal1 LIKE bsik-dmbtr, " Amount Totals
v_gtotal2 LIKE bsik-dmbtr, " Amount Totals
v_gtotal3 LIKE bsik-dmbtr, " Amount Totals
v_gtotal4 LIKE bsik-dmbtr, " Amount Totals
v_gtotal5 LIKE bsik-dmbtr, " Amount Totals
v_gtotal6 LIKE bsik-dmbtr, " Amount Totals
v_gtotal LIKE bsik-dmbtr, " Amount Totals
v_subtotal1 LIKE bsik-dmbtr, " Amount Totals
v_subtotal2 LIKE bsik-dmbtr, " Amount Totals
v_subtotal3 LIKE bsik-dmbtr, " Amount Totals
v_subtotal4 LIKE bsik-dmbtr, " Amount Totals
v_subtotal5 LIKE bsik-dmbtr, " Amount Totals
v_subtotal6 LIKE bsik-dmbtr, " Amount Totals
v_subtotal LIKE bsik-dmbtr, " Amount Totals
v_date LIKE bsik-zfbdt, " Due Date
v_tage1(4), " Age 30 days
v_tage2(4), " Age 60 days
v_tage3(4), " Age 90 days
v_fir(15), " Column Text1
v_sec(15), " Column Text2
v_thir(15), " Column Text3
v_four(17), " Column Text4
v_fidd(4), " Days field1
v_sedd(4), " Days field2
v_thdd(4), " Days field3
v_fodd(4), " Days field4
v_str TYPE SY-LISEL, " String
v_str1(11), " String
v_tage(3), " String
v_date1(10). " Date field
R A N G E D E C L A R A T I O N S
RANGES: r_date1 FOR bsik-zfbdt, " Date Range 1
r_date2 FOR bsik-zfbdt, " Date Range 2
r_date3 FOR bsik-zfbdt, " Date Range 3
r_date4 FOR bsik-zfbdt. " Date Range 4
S E L E C T I O N S C R E E N *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr. "Vendor account
PARAMETERS: p_bukrs LIKE t001-bukrs. "Co. Code
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_allgst LIKE rfpdo-allgstid OBLIGATORY DEFAULT sy-datum.
"Open items at key date
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETERS: p_tage1 LIKE rfpdo1-allgfael DEFAULT '30',
p_tage2 LIKE rfpdo1-allgfael DEFAULT '60',
p_tage3 LIKE rfpdo1-allgfael DEFAULT '90',
p_tage4 LIKE rfpdo1-allgfael DEFAULT '120'.
SELECTION-SCREEN END OF BLOCK b3.
A T S E L E C T I O N S C R E E N *
AT SELECTION-SCREEN.
Validate the screen fields
PERFORM validate_flds.
S T A R T O F S E L E C T I O N *
START-OF-SELECTION.
Fetch main data
PERFORM fetch_data.
T O P O F P A G E
Header
TOP-OF-PAGE.
PERFORM header.
E N D O F P A G E
Footer
END-OF-PAGE.
ULINE.
T O P O F P A G E D U R I N G L I N E S E L E C T I O N *
Top of Page in Secondary List
TOP-OF-PAGE DURING LINE-SELECTION.
PERFORM header1.
A T L I N E S E L E C T I O N *
AT LINE-SELECTION.
Perform Line Selections
PERFORM line_selection.
E N D O F S E L E C T I O N
END-OF-SELECTION.
List generation
PERFORM basic_list.
*& Form validate_flds
Validation of Selection Screen fields
FORM validate_flds .
Validate Vendor Code
CLEAR lfa1-lifnr.
SELECT lifnr UP TO 1 ROWS
INTO lfa1-lifnr
FROM lfa1
WHERE lifnr IN s_lifnr AND
spras = sy-langu.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Vendor Code range'(023).
ENDIF.
Validate Company Code
CLEAR t001-bukrs.
SELECT bukrs UP TO 1 ROWS
INTO t001-bukrs
FROM t001
WHERE bukrs = p_bukrs AND
spras = sy-langu.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e021. " Invalid Company Code range
ENDIF.
IF ( p_tage1 > p_tage2 ) OR ( p_tage1 > p_tage3 ) OR
( p_tage1 > p_tage4 ).
MESSAGE e999 WITH 'Column 1 greater'(004)
'than Column# 2 or 3 or 4'(005).
ENDIF.
*column 2
IF ( p_tage2 > p_tage3 ) OR ( p_tage1 > p_tage4 ).
MESSAGE e999 WITH 'Column 2 greater'(006)
'than Column# 3 or 4'(007).
ENDIF.
*column3
IF ( p_tage3 > p_tage4 ).
MESSAGE e999 WITH 'Column 3 greater'(008)
'than Column#4'(009).
ENDIF.
ENDFORM. " validate_flds
*& Form fetch_data
Fetching Data from Database Tables
FORM fetch_data .
Date Range Population
r_date1-sign = 'I'.
r_date1-option = 'BT'.
r_date1-low = p_allgst.
r_date1-high = r_date1-low + p_tage1.
APPEND r_date1.
r_date2-sign = 'I'.
r_date2-option = 'BT'.
r_date2-low = r_date1-high + 1.
r_date2-high = r_date1-low + p_tage2.
APPEND r_date2.
r_date3-sign = 'I'.
r_date3-option = 'BT'.
r_date3-low = r_date2-high + 1.
r_date3-high = r_date1-low + p_tage3.
APPEND r_date3.
r_date4-sign = 'I'.
r_date4-option = 'BT'.
r_date4-low = r_date3-high + 1.
r_date4-high = r_date1-low + p_tage4.
APPEND r_date4.
Select the Vendor Open Items data from BSIK
SELECT l~lifnr
l1~name1
b~waers
b~dmbtr
b~zfbdt
b~zbd1t
b~zbd2t
b~zbd3t
b~belnr
b~xblnr
b~shkzg
b~blart
INTO CORRESPONDING FIELDS OF TABLE int_bsik
FROM lfb1 AS l INNER JOIN lfa1 AS l1
ON llifnr = l1lifnr
INNER JOIN bsik AS b
ON llifnr = blifnr AND
lbukrs = bbukrs
WHERE l~lifnr IN s_lifnr AND
l~bukrs = p_bukrs and
b~zfbdt le p_allgst.
IF SY-SUBRC <> 0.
MESSAGE i000 WITH 'No Data found'(027).
ENDIF.
Removing the date limit to get the due items in the past
DELETE int_bsik WHERE
( blart NE 'RE' AND blart NE 'KR' ) OR
shkzg NE 'H'.
SORT int_bsik BY lifnr.
ENDFORM. " fetch_data
*& Form header
Display the Report Columns
FORM header .
v_tage1 = p_tage1 + 1.
v_tage2 = p_tage2 + 1.
v_tage3 = p_tage3 + 1.
v_fidd = p_tage1.
v_sedd = p_tage2.
v_thdd = p_tage3.
v_fodd = p_tage4.
MOVE v_fodd0(4) TO v_fodd1(3).
v_fodd+0(1) = space.
CONCATENATE '1 to'(010) v_fidd INTO v_fir.
CONCATENATE v_tage1 ' to '(011) v_sedd INTO v_sec.
CONCATENATE v_tage2 ' to '(011) v_thdd INTO v_thir.
CONCATENATE v_tage3 ' to '(011) space v_fodd INTO v_four.
Standard header
clear: v_date1, v_str, v_str1, v_tage.
write p_allgst to v_date1.
Move p_tage4 to v_tage.
concatenate '>' v_tage text-025 into v_str1.
concatenate
'Summary of Ageing Analysis for Vendor Open Invoices as on'(013)
v_date1 into v_str separated by space.
CALL FUNCTION 'Z_STANDARD_HEADER'
EXPORTING
title1 = 'Saudi International Petrochemical Company'(012)
title2 = v_str.
FORMAT COLOR OFF.
WRITE : /1(168) sy-uline.
FORMAT COLOR 1 INTENSIFIED.
WRITE :/1 sy-vline, 13 sy-vline, 49 sy-vline,
50(101) 'Invoices Due For(In Days)'(014) CENTERED,
151 sy-vline, 168 sy-vline .
WRITE :/1 sy-vline, 2(11) 'Vendor#'(015) CENTERED,
13 sy-vline ,14(35) 'Vendor Name'(016) CENTERED,
49 sy-vline,
50(101) sy-uline,151 sy-vline,
152(16) 'Total'(017) CENTERED,
168 sy-vline.
WRITE : /1 sy-vline,13 sy-vline, 49 sy-vline,
50(16) v_fir CENTERED, 66 sy-vline,
67(16) v_sec CENTERED, 83 sy-vline,
84(16) v_thir CENTERED, 100 sy-vline,
101(16) v_four CENTERED, 117 sy-vline,
118(16) v_str1 centered, 134 sy-vline,
135(16) 'Already Overdue'(018) CENTERED,151 sy-vline,
168 sy-vline.
FORMAT COLOR OFF.
WRITE : /1(168) sy-uline.
ENDFORM. " header
*& Form basic_list
Display the Basic List
FORM basic_list .
NEW-PAGE LINE-SIZE 168.
LOOP AT int_bsik.
CLEAR v_date.
IF int_bsik-zbd3t <> ' '.
v_date = int_bsik-zfbdt + int_bsik-zbd3t.
ELSE.
IF int_bsik-zbd2t <> ' '.
v_date = int_bsik-zfbdt + int_bsik-zbd2t.
ELSE.
v_date = int_bsik-zfbdt + int_bsik-zbd1t.
ENDIF.
ENDIF.
IF int_bsik-zbd1t = ' '.
v_date = int_bsik-zfbdt.
ENDIF.
IF v_date IN r_date1.
int_final-total1 = int_final-total1 + int_bsik-dmbtr.
ELSEIF v_date IN r_date2.
int_final-total2 = int_final-total2 + int_bsik-dmbtr.
ELSEIF v_date IN r_date3.
int_final-total3 = int_final-total3 + int_bsik-dmbtr.
ELSEIF v_date IN r_date4.
int_final-total4 = int_final-total4 + int_bsik-dmbtr.
ELSEif v_date > r_date4-high.
int_final-total5 = int_final-total5 + int_bsik-dmbtr.
ELSEif v_date < p_allgst.
int_final-total6 = int_final-total6 + int_bsik-dmbtr.
ENDIF.
AT END OF lifnr.
v_flag = 1.
ENDAT.
IF v_flag = 1.
int_final-lifnr = int_bsik-lifnr.
int_final-name1 = int_bsik-name1.
int_final-total = int_final-total1 + int_final-total2 +
int_final-total3 + int_final-total4 + int_final-total5 +
int_final-total6.
APPEND int_final.
v_gtotal1 = v_gtotal1 + int_final-total1.
v_gtotal2 = v_gtotal2 + int_final-total2.
v_gtotal3 = v_gtotal3 + int_final-total3.
v_gtotal4 = v_gtotal4 + int_final-total4.
v_gtotal5 = v_gtotal5 + int_final-total5.
v_gtotal6 = v_gtotal6 + int_final-total6.
v_gtotal = v_gtotal + int_final-total.
WRITE: /1 sy-vline,
2 int_final-lifnr COLOR 4 INTENSIFIED ON,
13 sy-vline,
14 int_final-name1 COLOR 4 INTENSIFIED ON,
49 sy-vline.
DATA : v_rem.
v_rem = sy-tabix MOD 2.
IF v_rem NE 0.
FORMAT COLOR 2 INTENSIFIED.
WRITE : 50 int_final-total1 CURRENCY int_bsik-waers,
66 sy-vline,
67 int_final-total2 CURRENCY int_bsik-waers,
83 sy-vline,
84 int_final-total3 CURRENCY int_bsik-waers,
100 sy-vline,
101 int_final-total4 CURRENCY int_bsik-waers,
117 sy-vline,
118 int_final-total5 CURRENCY int_bsik-waers,
134 sy-vline,
135 int_final-total6 CURRENCY int_bsik-waers,
151 sy-vline,
152 int_final-total CURRENCY int_bsik-waers,
168 sy-vline.
ELSE.
WRITE : 50 int_final-total1 CURRENCY int_bsik-waers,
66 sy-vline,
67 int_final-total2 CURRENCY int_bsik-waers,
83 sy-vline,
84 int_final-total3 CURRENCY int_bsik-waers,
100 sy-vline,
101 int_final-total4 CURRENCY int_bsik-waers,
117 sy-vline,
118 int_final-total5 CURRENCY int_bsik-waers,
134 sy-vline,
135 int_final-total6 CURRENCY int_bsik-waers,
151 sy-vline,
152 int_final-total CURRENCY int_bsik-waers,
168 sy-vline.
ENDIF.
FORMAT COLOR OFF.
HIDE int_final.
CLEAR int_final.
v_flag = 0.
ENDIF.
AT LAST.
WRITE : /1(168) sy-uline.
FORMAT COLOR 3 INTENSIFIED.
WRITE : /1 sy-vline, 2(47) 'GRAND TOTAL'(022) CENTERED,
49 sy-vline, 50 v_gtotal1 CURRENCY int_bsik-waers,
66 sy-vline, 67 v_gtotal2 CURRENCY int_bsik-waers,
83 sy-vline, 84 v_gtotal3 CURRENCY int_bsik-waers,
100 sy-vline,101 v_gtotal4 CURRENCY int_bsik-waers,
117 sy-vline,118 v_gtotal5 CURRENCY int_bsik-waers,
134 sy-vline,135 v_gtotal6 CURRENCY int_bsik-waers,
151 sy-vline,152 v_gtotal CURRENCY int_bsik-waers,
168 sy-vline.
HIDE : v_gtotal1,
v_gtotal2,
v_gtotal3,
v_gtotal4,
v_gtotal5,
v_gtotal6,
v_gtotal.
ENDAT.
FORMAT COLOR OFF.
ENDLOOP.
WRITE : /1(168) sy-uline.
ENDFORM. " basic_list
*& Form line_selection
When double clicked on the line display the seconday list
FORM line_selection .
NEW-PAGE LINE-SIZE 206.
Sy-lsind = 1.
DATA : v_rem,v_cnt LIKE sy-tabix.
v_cnt = 0.
SORT int_bsik BY belnr zfbdt.
LOOP AT int_bsik WHERE lifnr EQ int_final-lifnr.
v_rem = v_cnt MOD 2.
CLEAR v_date.
IF int_bsik-zbd3t <> ' '.
v_date = int_bsik-zfbdt + int_bsik-zbd3t.
ELSE.
IF int_bsik-zbd2t <> ' '.
v_date = int_bsik-zfbdt + int_bsik-zbd2t.
ELSE.
v_date = int_bsik-zfbdt + int_bsik-zbd1t.
ENDIF.
ENDIF.
IF int_bsik-zbd1t = ' '.
v_date = int_bsik-zfbdt.
ENDIF.
IF v_rem NE 0.
format color 2 intensified.
WRITE :/1 sy-vline, 2 int_bsik-belnr,
12 sy-vline,13 int_bsik-lifnr,
23 sy-vline,24 int_bsik-name1,
59 sy-vline,60 int_bsik-xblnr,
76 sy-vline,77 int_bsik-zfbdt,
87 sy-vline.
WRITE : 104 sy-vline,121 sy-vline,
138 sy-vline,155 sy-vline,
172 sy-vline, 189 sy-vline,
190 int_bsik-dmbtr CURRENCY int_bsik-waers,
206 sy-vline.
IF v_date IN r_date1.
v_subtotal1 = v_subtotal1 + int_bsik-dmbtr.
WRITE : 88 int_bsik-dmbtr CURRENCY int_bsik-waers.
ELSEIF v_date IN r_date2.
v_subtotal2 = v_subtotal2 + int_bsik-dmbtr.
WRITE : 105 int_bsik-dmbtr CURRENCY int_bsik-waers.
ELSEIF v_date IN r_date3.
v_subtotal3 = v_subtotal3 + int_bsik-dmbtr.
WRITE : 122 int_bsik-dmbtr CURRENCY int_bsik-waers.
ELSEIF v_date IN r_date4.
v_subtotal4 = v_subtotal4 + int_bsik-dmbtr.
WRITE : 139 int_bsik-dmbtr CURRENCY int_bsik-waers.
ELSEif v_date > r_date4-high.
v_subtotal5 = v_subtotal5 + int_bsik-dmbtr.
WRITE : 156 int_bsik-dmbtr CURRENCY int_bsik-waers.
ELSEif v_date < p_allgst.
v_subtotal6 = v_subtotal6 + int_bsik-dmbtr.
WRITE : 173 int_bsik-dmbtr CURRENCY int_bsik-waers.
ENDIF.
format color off.
ELSE.
WRITE :/1 sy-vline, 2 int_bsik-belnr,
12 sy-vline,13 int_bsik-lifnr,
23 sy-vline,24 int_bsik-name1,
59 sy-vline,60 int_bsik-xblnr,
76 sy-vline,77 int_bsik-zfbdt,
87 sy-vline.
WRITE : 104 sy-vline,121 sy-vline,
138 sy-vline,155 sy-vline,
172 sy-vline,189 sy-vline,
190 int_bsik-dmbtr CURRENCY int_bsik-waers,
206 sy-vline.
IF v_date IN r_date1.
v_subtotal1 = v_subtotal1 + int_bsik-dmbtr.
WRITE : 88 int_bsik-dmbtr CURRENCY int_bsik-waers.
ELSEIF v_date IN r_date2.
v_subtotal2 = v_subtotal2 + int_bsik-dmbtr.
WRITE : 105 int_bsik-dmbtr CURRENCY int_bsik-waers.
ELSEIF v_date IN r_date3.
v_subtotal3 = v_subtotal3 + int_bsik-dmbtr.
WRITE : 122 int_bsik-dmbtr CURRENCY int_bsik-waers.
ELSEIF v_date IN r_date4.
v_subtotal4 = v_subtotal4 + int_bsik-dmbtr.
WRITE : 139 int_bsik-dmbtr CURRENCY int_bsik-waers.
ELSEif v_date > r_date4-high.
v_subtotal5 = v_subtotal5 + int_bsik-dmbtr.
WRITE : 156 int_bsik-dmbtr CURRENCY int_bsik-waers.
ELSEif v_date < p_allgst.
v_subtotal6 = v_subtotal6 + int_bsik-dmbtr.
WRITE : 173 int_bsik-dmbtr CURRENCY int_bsik-waers.
ENDIF.
ENDIF.
FORMAT COLOR OFF.
v_cnt = v_cnt + 1.
ENDLOOP.
WRITE : /1(206) sy-uline.
v_subtotal = v_subtotal1 + v_subtotal2 + v_subtotal3
+ v_subtotal4 + v_subtotal5 + v_subtotal6.
FORMAT COLOR 3 INTENSIFIED.
WRITE : /1 sy-vline,
2(85) 'Total'(017) CENTERED CURRENCY int_bsik-waers ,
87 sy-vline,
88 v_subtotal1 CURRENCY int_bsik-waers,
104 sy-vline,
105 v_subtotal2 CURRENCY int_bsik-waers,
121 sy-vline,
122 v_subtotal3 CURRENCY int_bsik-waers,
138 sy-vline,
139 v_subtotal4 CURRENCY int_bsik-waers,
155 sy-vline,
156 v_subtotal5 CURRENCY int_bsik-waers,
172 sy-vline,
173 v_subtotal6 CURRENCY int_bsik-waers,
189 sy-vline,
190 v_subtotal CURRENCY int_bsik-waers,
206 sy-vline.
FORMAT COLOR OFF.
WRITE : /1(206) sy-uline.
CLEAR : v_subtotal,v_subtotal1,v_subtotal2,v_subtotal3,
v_subtotal4,v_subtotal5,v_gtotal1,v_gtotal2,v_gtotal3,
v_gtotal4, v_gtotal5,v_gtotal,v_subtotal6,v_gtotal6.
ENDFORM. " line_selection
*& Form header1
Secondary List Header
FORM header1 .
Standard header
clear: v_date1, v_str, v_str1, v_tage.
write p_allgst to v_date1.
Move p_tage4 to v_tage.
concatenate '>' v_tage text-025 into v_str1.
concatenate
'Details of Ageing Analysis for Vendor Open Invoices as on'(024)
v_date1 into v_str separated by space.
CALL FUNCTION 'Z_STANDARD_HEADER'
EXPORTING
title1 = 'Company'(012)
title2 = v_str.
FORMAT COLOR 1 intensified.
WRITE :/1(206) sy-uline.
WRITE :/1 sy-vline,12 sy-vline ,
23 sy-vline,59 sy-vline,76 sy-vline,87 sy-vline,
88(101) 'Invoices Due For(In Days)'(014) CENTERED,
189 sy-vline,206 sy-vline.
WRITE : /1 sy-vline, 2(10) 'Doc Number'(021) CENTERED,
12 sy-vline, 13(10) 'Vendor#'(015) CENTERED,
23 sy-vline, 24(35) 'Vendor Name'(016) CENTERED,
59 sy-vline, 60(16) 'Ref invoice#'(019) CENTERED,
76 sy-vline, 77(10) 'Inv dt'(020) CENTERED,
87 sy-vline, 88(101) sy-uline,
189 sy-vline,190(16) 'Total'(017) CENTERED,
206 sy-vline.
WRITE : /1 sy-vline, 12 sy-vline,
23 sy-vline,59 sy-vline,
76 sy-vline,87 sy-vline,
88(16) v_fir CENTERED, 104 sy-vline,
105(16) v_sec CENTERED, 121 sy-vline,
122(16) v_thir CENTERED, 138 sy-vline,
139(16) v_four CENTERED, 155 sy-vline,
156(16) v_str1 CENTERED,
172 sy-vline,
173(16) 'Already Overdue'(018) CENTERED,
189 sy-vline,
206 sy-vline.
format color off.
WRITE : /1(206) sy-uline.
ENDFORM. " header1
Reward points if useful
Regards
Anji -
URGENT check the code for vendor ageing (Give Solution)
hi this is the code which i am using to calculate the
ageing but not able to get the result.
every time the result is 0.plz suggest me the solution.
its very urgent.
*& Report Z_VENDOR AGEING *
*& in this repoet I am calculating the vendor ageing
which is depending on formula
AGEING = Current Date(or any date entered by user) Bline Date(BSIK-zfbdt)
REPORT z_vendor NO STANDARD PAGE HEADING
LINE-SIZE 200
LINE-COUNT 65(3).
TABLES : bsik.
DATA : BEGIN OF t_out OCCURS 0,
bukrs LIKE bsik-bukrs,
saknr LIKE bsik-saknr,
bldat LIKE bsik-bldat,
wrbtr LIKE bsik-wrbtr,
lifnr LIKE bsik-lifnr,
zfbdt like bsik-zfbdt,
ageing type i,
END OF t_out.
parameters : p_date1 type d.
SELECT-OPTIONS : s_bukrs FOR bsik-bukrs,
s_saknr FOR bsik-saknr,
s_lifnr FOR bsik-lifnr.
SELECT bukrs saknr bldat wrbtr lifnr zfbdt
FROM bsik
INTO TABLE t_out
WHERE saknr IN s_saknr
AND bukrs IN s_bukrs
AND lifnr IN s_lifnr.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = p_date1
i_datum_von = t_out-zfbdt
I_KZ_EXCL_VON = '0'
I_KZ_INCL_BIS = '0'
I_KZ_ULT_BIS = ' '
I_KZ_ULT_VON = ' '
I_STGMETH = '0'
I_SZBMETH = '1'
IMPORTING
E_TAGE = t_out-ageing
EXCEPTIONS
DAYS_METHOD_NOT_DEFINED = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT t_out.
WRITE : / t_out-saknr,
t_out-lifnr,
t_out-wrbtr,
t_out-zfbdt,
t_out-ageing.
ENDLOOP.hi sanjeev,
still problem there.
dont worry. just copy this code.
try this code.
TABLES : bsik.
DATA : BEGIN OF t_out OCCURS 0,
bukrs LIKE bsik-bukrs,
saknr LIKE bsik-saknr,
bldat LIKE bsik-bldat,
wrbtr LIKE bsik-wrbtr,
lifnr LIKE bsik-lifnr,
zfbdt like bsik-zfbdt,
ageing type i,
END OF t_out.
parameters : p_date1 type d.
SELECT-OPTIONS : s_bukrs FOR bsik-bukrs,
s_saknr FOR bsik-saknr,
s_lifnr FOR bsik-lifnr.
SELECT bukrs saknr bldat wrbtr lifnr zfbdt
FROM bsik
INTO <b>corresponding fields of</b> TABLE t_out
WHERE saknr IN s_saknr
AND bukrs IN s_bukrs
AND lifnr IN s_lifnr.
<b>loop at t_out.</b>
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = p_date1
i_datum_von = t_out-zfbdt
I_KZ_EXCL_VON = '0'
I_KZ_INCL_BIS = '0'
I_KZ_ULT_BIS = ' '
I_KZ_ULT_VON = ' '
I_STGMETH = '0'
I_SZBMETH = '1'
IMPORTING
E_TAGE = t_out-ageing
EXCEPTIONS
DAYS_METHOD_NOT_DEFINED = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
<b>modify t_out.</b>
clear t_out.
<b>endloop.</b>
LOOP AT t_out.
WRITE : / t_out-saknr,
t_out-lifnr,
t_out-wrbtr,
t_out-zfbdt,
t_out-ageing.
endloop
rgds
anver
Message was edited by: Anversha s -
hi friends,
Help me how to do this
REPORT ZINTERFACE_SAMPLE.
type-pools:SLIS.
TABLES:knb1, "Customer Master (Company Code)
kna1,
knvp. "Customer Master Partner Functions
TYPES:BEGIN OF T_knb1,
kunnr like knb1-kunnr,
bukrs like knb1-bukrs,
akont like knb1-akont,
END OF T_knb1.
TYPES:BEGIN OF T_kna1,
kunnr like kna1-kunnr, "customer number
NAME1 like KNA1-NAME1, "customer name
stras like KNA1-STRAS, "Customer address
ort01 like KNA1-ORT01, "Customer city
stcd1 like KNA1-STCD1, "Tax id
pstlz like KNA1-PSTLZ, "Postal code
END OF T_kna1.
TYPES:BEGIN OF T_knvp,
kunnr like knvp-kunnr, "customer number
parvw like knvp-parvw,
kunn2 like knvp-kunn2, "Customer number of business partner
END OF T_KNVP.
TYPES:BEGIN OF T_final,
Record_type TYPE c,
Sold_to_cust(10) TYPE c,
Payer(10) TYPE c,
Sequence(5) TYPE n,
Cust_name(35) TYPE c,
Cust_adreess(35) TYPE c,
Cust_city(35) TYPE c,
Tax_id(16) TYPE c,
Postal_code(5) TYPE c,
Branch TYPE c,
Delivery(3) TYPE c,
END OF T_final.
*Internal table declaration
DATA:I_knb1 TYPE STANDARD TABLE OF t_knb1 initial size 0,
i_kna1 TYPE STANDARD TABLE OF t_kna1 initial size 0,
i_knvp TYPE STANDARD TABLE OF t_knvp initial size 0,
i_final TYPE STANDARD TABLE OF t_final initial size 0.
DATA: t_fieldcat_tab TYPE slis_t_fieldcat_alv WITH HEADER LINE.
*Work area declaration
DATA:wa_knb1 TYPE t_knb1,
wa_kna1 TYPE t_kna1,
wa_knvp TYPE t_knvp,
wa_final TYPE t_final.
*variable declaration
data:sequence TYPe n,
g_line TYPE i.
selection screen *
SELECTION-screen begin of block b1 with frame title text-001.
parameters:p_bukrs like knb1-bukrs, "Company code
p_akont like knb1-akont .
selection-screen end of block b1.
SELECTION-screen begin of block b2 with frame title text-002.
PARAMETERS:R1 RADIOBUTTON GROUP G1,
R2 RADIOBUTTON GROUP G1.
Parameters:p_file like rlgrap-filename.
"Recon Account in General Ledger
selection-screen end of block b2.
*AT selection-screen ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.
START-OF-selection.
PERFORM f_fetchdata.
PERFORM f_prepare_fieldcat.
PERFORM f_display_report.
*END-OF-SELECTION.
*IF R1 EQ 'X'.
*perform F_DOWNLOAD.
*ENDIF.
*IF R2 EQ 'X'.
*OPEN DATASET P_FILE FOR OUTPUT IN text mode ENCODING DEFAULT.
*LOOP AT i_final INTO WA_final.
*TRANSFER WA_final TO P_FILE.
*ENDLOOP.
*CLOSE DATASET P_FILE.
*ENDIF.
*& Form f_fetchdata
FORM f_fetchdata .
select kunnr
bukrs
akont
from knb1
into table i_knb1
where bukrs = p_bukrs
AND akont = p_akont.
DESCRIBE TABLE i_knb1 LINES g_line.
LOOP AT i_knb1 INTO wa_knb1.
SELECT single KUNNR
NAME1
STRAS
ORT01
STCD1
PSTLZ
FROM kna1
INTO wa_kna1
where kunnr = wa_knb1-kunnr.
if sy-subrc <> 0.
*Error KNA1 record not found.
endif.
SELECT single kunnr
parvw
kunn2
FROM KNVP
INTO wa_knvp
where kunnr = wa_knb1-kunnr
AND parvw = 'RG'.
if sy-subrc <> 0.
*Error KNA1 record not found.
endif.
sequence = sequence + 1.
MOVE: 'c' TO wa_final-Record_type,
wa_knvp-kunnr TO wa_final-Sold_to_cust,
sequence TO wa_final-Sequence,
wa_KNA1-NAME1 TO wa_final-Cust_name,
wa_kna1-STRAS TO wa_final-Cust_adreess ,
wa_kna1-ort01 TO wa_final-Cust_city,
wa_kna1-STCD1 TO wa_final-Tax_id,
wa_kna1-PSTLZ TO wa_final-Postal_code,
'1' TO wa_final-branch,
'abc' TO wa_final-Delivery.
INSERT wa_final INTO TABLE i_final.
endloop.
ENDFORM. " f_fetchdata
FORM f_prepare_fieldcat.
t_fieldcat_tab-col_pos = 1.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Record_type'.
t_fieldcat_tab-seltext_l = 'Record type'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 2.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Sold_to_cust'.
t_fieldcat_tab-seltext_l = 'Sold to cust'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 3.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'payer'.
t_fieldcat_tab-seltext_l = 'Payer'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 4.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Sequence'.
t_fieldcat_tab-seltext_l = 'sequence'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 5.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Cust_name'.
t_fieldcat_tab-seltext_l = 'Cust name'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 6.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Cust_adreess'.
t_fieldcat_tab-seltext_l = 'Cust adreess'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 7.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Cust_city'.
t_fieldcat_tab-seltext_l = 'Cust city'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 8.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Tax_id'.
t_fieldcat_tab-seltext_l = 'Tax id'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 9.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Postal_code'.
t_fieldcat_tab-seltext_l = 'Postal code'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 10.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Branch'.
t_fieldcat_tab-seltext_l = 'Branch'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 11.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'KWMENG'.
t_fieldcat_tab-seltext_l = 'Order Qty'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 12.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Delivery'.
t_fieldcat_tab-seltext_l = 'Delivery'.
APPEND t_fieldcat_tab.
ENDFORM. " f_prepare_fieldcat
*& Form f_display_report
*To display the ALV Report
FORM f_display_report.
DATA: l_repid LIKE sy-repid.
l_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = l_repid
i_buffer_active = 'X'
IT_FIELDCAT = t_fieldcat_tab[]
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = i_final[].
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM." f_display_report
*& Form F_DOWNLOAD
text
--> p1 text
<-- p2 text
FORM F_DOWNLOAD .
*CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = p_file
FILETYPE = 'ASC'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = i_final
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
*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. " F_DOWNLOAD
for this one when i given the proper input
it showing the Runtime error.
Could u please tell me what mistake i have done
Urgent help
Regards
harshavi N.HI,
Run this program..
REPORT ZINTERFACE_SAMPLE.
type-pools:SLIS.
TABLES:knb1, "Customer Master (Company Code)
kna1,
knvp. "Customer Master Partner Functions
TYPES:BEGIN OF T_knb1,
kunnr like knb1-kunnr,
bukrs like knb1-bukrs,
akont like knb1-akont,
END OF T_knb1.
TYPES:BEGIN OF T_kna1,
kunnr like kna1-kunnr, "customer number
NAME1 like KNA1-NAME1, "customer name
stras like KNA1-STRAS, "Customer address
ort01 like KNA1-ORT01, "Customer city
stcd1 like KNA1-STCD1, "Tax id
pstlz like KNA1-PSTLZ, "Postal code
END OF T_kna1.
TYPES:BEGIN OF T_knvp,
kunnr like knvp-kunnr, "customer number
parvw like knvp-parvw,
kunn2 like knvp-kunn2, "Customer number of business partner
END OF T_KNVP.
TYPES:BEGIN OF T_final,
Record_type TYPE c,
Sold_to_cust(10) TYPE c,
Payer(10) TYPE c,
Sequence(5) TYPE n,
Cust_name(35) TYPE c,
Cust_adreess(35) TYPE c,
Cust_city(35) TYPE c,
Tax_id(16) TYPE c,
Postal_code(5) TYPE c,
Branch TYPE c,
Delivery(3) TYPE c,
END OF T_final.
*Internal table declaration
DATA:I_knb1 TYPE STANDARD TABLE OF t_knb1 initial size 0,
i_kna1 TYPE STANDARD TABLE OF t_kna1 initial size 0,
i_knvp TYPE STANDARD TABLE OF t_knvp initial size 0,
i_final TYPE STANDARD TABLE OF t_final initial size 0.
DATA: t_fieldcat_tab TYPE slis_t_fieldcat_alv WITH HEADER LINE.
*Work area declaration
DATA:wa_knb1 TYPE t_knb1,
wa_kna1 TYPE t_kna1,
wa_knvp TYPE t_knvp,
wa_final TYPE t_final.
*variable declaration
data:sequence TYPe n,
g_line TYPE i.
selection screen *
SELECTION-screen begin of block b1 with frame title text-001.
parameters:p_bukrs like knb1-bukrs, "Company code
p_akont like knb1-akont .
selection-screen end of block b1.
SELECTION-screen begin of block b2 with frame title text-002.
PARAMETERS:R1 RADIOBUTTON GROUP G1,
R2 RADIOBUTTON GROUP G1.
Parameters:p_file like rlgrap-filename.
"Recon Account in General Ledger
selection-screen end of block b2.
*AT selection-screen ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.
START-OF-selection.
PERFORM f_fetchdata.
PERFORM f_prepare_fieldcat.
PERFORM f_display_report.
*END-OF-SELECTION.
*IF R1 EQ 'X'.
*perform F_DOWNLOAD.
*ENDIF.
*IF R2 EQ 'X'.
*OPEN DATASET P_FILE FOR OUTPUT IN text mode ENCODING DEFAULT.
*LOOP AT i_final INTO WA_final.
*TRANSFER WA_final TO P_FILE.
*ENDLOOP.
*CLOSE DATASET P_FILE.
*ENDIF.
*& Form f_fetchdata
FORM f_fetchdata .
select kunnr
bukrs
akont
from knb1
into table i_knb1
where bukrs = p_bukrs
AND akont = p_akont.
DESCRIBE TABLE i_knb1 LINES g_line.
LOOP AT i_knb1 INTO wa_knb1.
SELECT single KUNNR
NAME1
STRAS
ORT01
STCD1
PSTLZ
FROM kna1
INTO wa_kna1
where kunnr = wa_knb1-kunnr.
if sy-subrc <> 0.
*Error KNA1 record not found.
endif.
SELECT single kunnr
parvw
kunn2
FROM KNVP
INTO wa_knvp
where kunnr = wa_knb1-kunnr
AND parvw = 'RG'.
if sy-subrc <> 0.
*Error KNA1 record not found.
endif.
sequence = sequence + 1.
MOVE: 'c' TO wa_final-Record_type,
wa_knvp-kunnr TO wa_final-Sold_to_cust,
sequence TO wa_final-Sequence,
wa_KNA1-NAME1 TO wa_final-Cust_name,
wa_kna1-STRAS TO wa_final-Cust_adreess ,
wa_kna1-ort01 TO wa_final-Cust_city,
wa_kna1-STCD1 TO wa_final-Tax_id,
wa_kna1-PSTLZ TO wa_final-Postal_code,
'1' TO wa_final-branch,
'abc' TO wa_final-Delivery.
INSERT wa_final INTO TABLE i_final.
endloop.
ENDFORM. " f_fetchdata
FORM f_prepare_fieldcat.
t_fieldcat_tab-col_pos = 1.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'RECORD_TYPE'.
t_fieldcat_tab-seltext_l = 'Record type'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 2.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'SOLD_TO_CUST'.
t_fieldcat_tab-seltext_l = 'Sold to cust'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 3.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'PAYER'.
t_fieldcat_tab-seltext_l = 'Payer'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 4.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'SEQUENCE'.
t_fieldcat_tab-seltext_l = 'sequence'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 5.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'CUST_NAME'.
t_fieldcat_tab-seltext_l = 'Cust name'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 6.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'CUST_ADREESS'.
t_fieldcat_tab-seltext_l = 'Cust adreess'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 7.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'CUST_CITY'.
t_fieldcat_tab-seltext_l = 'Cust city'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 8.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'TAX_ID'.
t_fieldcat_tab-seltext_l = 'Tax id'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 9.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'POSTAL_CODE'.
t_fieldcat_tab-seltext_l = 'Postal code'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 10.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'BRANCH'.
t_fieldcat_tab-seltext_l = 'Branch'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 11.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'KWMENG'.
t_fieldcat_tab-seltext_l = 'Order Qty'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 12.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'DELIVERY'.
t_fieldcat_tab-seltext_l = 'Delivery'.
APPEND t_fieldcat_tab.
ENDFORM. " f_prepare_fieldcat
*& Form f_display_report
*To display the ALV Report
FORM f_display_report.
DATA: l_repid LIKE sy-repid.
l_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = l_repid
IT_FIELDCAT = t_fieldcat_tab[]
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_FINAL[].
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM." f_display_report
*& Form F_DOWNLOAD
text
--> p1 text
<-- p2 text
FORM F_DOWNLOAD .
*CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = p_file
FILETYPE = 'ASC'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = i_final
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
*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. " F_DOWNLOAD
It is perfectly working for me..
I made the field name and table name as CAPs in the field catalog internal table.
I removed the buffer paramter in the ALV FM.
Thanks,
Naren -
URGENT ----- Problem in converting spool to pdf .
Error - File cannot be opened because of no pages ......
Hi experts,
I am passing internal table contents to spool --> then spool to pdf -
> then mail sending.
Everything is fine but only error is in the receiving mail the above error is coming.
given the code...
<b>I think the error is in converting into pdf function module</b>
<b>Help me to solve this problem as it is very urgent</b>
include data_declare. " pasted down
select * from kna1 into table itab up to 50 rows.
CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'
EXPORTING
dest = 'LP01'
immediate_print = 'X'
IMPORTING
handle = handle
SPOOLID = spoolid.
loop at itab.
concatenate itab-kunnr itab-name1 itab-land1 into text separated by
space.
CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'
EXPORTING
handle = handle
text = text.
endloop.
CALL FUNCTION 'RSPO_CLOSE_SPOOLREQUEST'
EXPORTING
handle = handle.
Convert Spool to PDF **********************************
<b>CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spoolid "gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.</b>
Processing Mail Sending ************************************
DATA: p_email LIKE somlreci1-receiver,
p_sender LIKE somlreci1-receiver,
sub(40).
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = text-002.
it_mess_bod = text-001.
APPEND it_mess_bod.
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
MOVE 'Orders Rejeced on' TO sub.
WRITE: sy-datum DD/MM/YYYY TO sub+27(10).
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
TABLES it_mess_bod
it_mess_att
USING
p_email
sub "text-009
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
CHANGING gd_error
gd_reciever.
ENDFORM. " process_email
*& Form send_file_as_email_attachment
text
-->P_IT_MESS_BOD text
-->P_IT_MESS_ATT text
-->P_TEXT_009 text
-->P_1058 text
-->P_GD_ATTACHMENT_NAME text
-->P_GD_ATTACHMENT_DESC text
<--P_GD_ERROR text
<--P_GD_RECIEVER text
FORM send_file_as_email_attachment TABLES it_message
it_attach
USING
p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
CHANGING p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
CLEAR gt_mail.
SELECT SINGLE * FROM zmail INTO gt_mail
WHERE grpnr = '1'.
IF NOT gt_mail-mail1 IS INITIAL.
t_receivers-receiver = gt_mail-mail1.
APPEND t_receivers.
ENDIF.
IF NOT gt_mail-mail2 IS INITIAL.
t_receivers-receiver = gt_mail-mail2.
APPEND t_receivers.
ENDIF.
IF NOT gt_mail-mail3 IS INITIAL.
t_receivers-receiver = gt_mail-mail3.
APPEND t_receivers.
ENDIF.
IF NOT gt_mail-mail4 IS INITIAL.
t_receivers-receiver = gt_mail-mail4.
APPEND t_receivers.
ENDIF.
LOOP AT gt_mail.
t_receivers-receiver = gt_mail-mailid..
APPEND t_receivers.
ENDLOOP.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM. " send_file_as_email_attachment
Data Declaration ************************************
DATA : handle LIKE sy-tabix.
data itab like kna1 occurs 0 with header line.
data: text(50) type c.
data: spoolid type TSP01-RQIDENT.
DATA : gt_listobject LIKE abaplist OCCURS 10 .
DATA : gt_objcont LIKE soli OCCURS 10 WITH HEADER LINE.
DATA : gt_objcont1 LIKE soli OCCURS 10 WITH HEADER LINE.
DATA : gt_objhead LIKE soli OCCURS 10 WITH HEADER LINE.
DATA : gt_att_head LIKE soli OCCURS 10 WITH HEADER LINE.
DATA : gt_receivers LIKE soos1 OCCURS 10 WITH HEADER LINE.
DATA : gt_packing_list LIKE soxpl OCCURS 10 WITH HEADER LINE.
DATA : gt_so_ali LIKE soli OCCURS 100 WITH HEADER LINE.
DATA : gt_so_ali1 LIKE soli OCCURS 100 WITH HEADER LINE.
DATA : gt_document_data LIKE sood1.
DATA: lineno TYPE i , length TYPE i , size TYPE i.
DATA: gt_message LIKE soli OCCURS 10 WITH HEADER LINE,
gt_message1 LIKE soli OCCURS 10 WITH HEADER LINE.
DATA: gt_scheme LIKE ztrc_scheme OCCURS 0 WITH HEADER LINE,
gt_mail LIKE zmail_prov OCCURS 0 WITH HEADER LINE.
gt_mail LIKE zmail." occurs 0 with header line.
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
DATA: check TYPE c,
days TYPE i.
<b></b><b></b><b></b>Hi Prashant,
Thanks for your reply. Really it is very useful one.
In this, the output list is getting populated into spool and to pdf.
But my requirement sending the internal table contents to spool directly without dispalying in the output list.
I did the program like the above mentioned one already. But my requirement is not that one.
Regards
chakradhar -
Open items for purchase order its very urgent
hi
my requirement is to write extract program for purchase order(me21) to extract only open items.
please provide sample code its very urgent.
thanks in advance.
points will be rewarded.
thanks
hari prasad reddycheck the below report :
REPORT ZMM_OPEN_PO_REPORT no standard page heading
line-size 255
message-id zwave.
======================================================================
Program Name : ZMM_OPEN_PO_REPORT *
Description : This report displays all Open PO Items and output *
would be PO Number,Material number and so on *
Author : Seshu *
Date : 01/24/2007 *
MODIFICATION HISTORY *
DATE | AUTHOR | CHANGE # | DESCRIPTION OF MODIFICATION *
--|||--
01/24/07| Seshu | DEVK921979 | Initial *
D A T A D E C L A R A T I O N P A R T ***
type-pools
type-pools : slis.
Tables
tables : ekko, " Purchase order Header
ekpo, " Purchase order Item
marc. " Material with Plant data
Internal table for output.
data : begin of i_output occurs 0,
ebeln like ekko-ebeln,
matnr like ekpo-matnr,
end of i_output.
ALV Data declaration.
data : v_repid like sy-repid.
ALV Function Module Variables
DATA: gs_layout type slis_layout_alv,
g_exit_caused_by_caller,
gs_exit_caused_by_user type slis_exit_by_user.
DATA: gt_fieldcat type slis_t_fieldcat_alv,
gs_print type slis_print_alv,
gt_events type slis_t_event,
gt_list_top_of_page type slis_t_listheader,
g_status_set type slis_formname value 'PF_STATUS_SET',
g_user_command type slis_formname value 'USER_COMMAND',
g_top_of_page type slis_formname value 'TOP_OF_PAGE',
g_top_of_list type slis_formname value 'TOP_OF_LIST',
g_end_of_list type slis_formname value 'END_OF_LIST',
g_variant LIKE disvariant,
g_save(1) TYPE c,
g_tabname_header TYPE slis_tabname,
g_tabname_item TYPE slis_tabname,
g_exit(1) TYPE c,
gx_variant LIKE disvariant.
data : gr_layout_bck type slis_layout_alv.
Ranges
ranges r_eindt for eket-eindt.
initialization.
v_repid = sy-repid.
start-of-selection.
Get the data from EKKO ,EKPO and MARC Table
perform get_data_tables.
end-of-selection.
display the data in the form of ALV
perform display_data.
*& Form get_data_tables
Get the data from EKKO,EKPO and MARC Table
FORM get_data_tables.
clear : i_output.
refresh : i_output.
fill the dates in ranges
r_eindt-low = sy-datum - 7.
r_eindt-high = sy-datum + 14.
r_eindt-option = 'BT'.
r_eindt-sign = 'I'.
append r_eindt.
Get the data from EKKO,EKPO and EKET Tables
select aebeln bmatnr into table i_output
from ekko as a inner join
ekpo as b on aebeln = bebeln
inner join marc as c on cmatnr = bmatnr
inner join mara as d on dmatnr = bmatnr
inner join eket as e on eebeln = aebeln
and eebelp = bebelp
where c~beskz = 'E'
and c~werks = '1000'
and d~mtart = 'FERT'
and b~loekz = space
and b~elikz = space
and e~eindt in r_eindt.
if sy-subrc ne 0.
message e000(zwave) with 'No open purchase order found'.
endif.
ENDFORM. " get_data_tables
*& Form display_data
text
FORM display_data.
Fill the Fiedlcat
PERFORM fieldcat_init using gt_fieldcat[].
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = g_user_command
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = gr_layout_bck
IT_FIELDCAT = gt_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = g_save
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = i_output
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " display_data
*& Form fieldcat_init
text
-->P_GT_FIELDCAT[] text
FORM fieldcat_init USING e01_lt_fieldcat type slis_t_fieldcat_alv.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
Purchase order number
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'EBELN'.
LS_FIELDCAT-ref_fieldname = 'EBELN'.
LS_FIELDCAT-ref_tabname = 'EKKO'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Purchase Order'.
ls_fieldcat-seltext_M = 'Purchase Order'.
ls_fieldcat-seltext_S = 'Purchase Order'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Material #
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MATNR'.
LS_FIELDCAT-ref_fieldname = 'MATNR'.
LS_FIELDCAT-ref_tabname = 'EKPO'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Material'.
ls_fieldcat-seltext_M = 'Material'.
ls_fieldcat-seltext_S = 'Material'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
ENDFORM. " fieldcat_init -
Communication b/w SAP and VB .exe file - Very urgent.
hi,
I am currently in a project implementing SAP for a cement manufacturing company. Here we have a VB .exe file which takes parameters and return values. now we need to connect this to application to SAP R/3 to pass data to that application and access the data from that .exe file.
Note: we don't have any source code for that vb .exe file its a third party software.
Its an very urgent one....
please guide me how to do it with all steps.
Any material please pass to [email protected]
Thanks in advance.form grosswt .
refresh itab3.
clear itab3.
Executing VB EXE file to get the weight from weigh bridge
call function 'WS_EXECUTE'
exporting
DOCUMENT = ' '
CD = ' '
COMMANDLINE = ' '
inform = 'X'
cd = 'C:\SAPWEI'
program = 'C:\sapwei\MyVB.exe'
STAT = ' '
WINID = ' '
OSMAC_SCRIPT = ' '
OSMAC_CREATOR = ' '
WIN16_EXT = ' '
EXEC_RC = ' '
IMPORTING
RBUFF =
EXCEPTIONS
FRONTEND_ERROR = 1
NO_BATCH = 2
PROG_NOT_FOUND = 3
ILLEGAL_OPTION = 4
GUI_REFUSE_EXECUTE = 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.
Fetching Value from VB text file
call function 'WS_UPLOAD'
exporting
CODEPAGE = ' '
filename = 'C:\sapwei\w1.txt'
FILETYPE = 'ASC'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
tables
data_tab = itab3
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
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 itab3.
v1 = itab3-num.
pgrwt = v1.
endloop.
message 'Save Gross Weight' type 'S'.
endform. " grosswt -
URGENT!!! Extraction by FM is not working after entering No_MORE_DATA
Hi Experts,
We are trying to extract data from a custom table and look up cdhdr and cdpos table for change log for recrods in that custom table. I created a generic datasource with an abaper who defined a self defined FM below which is a copy of the RSAX_BIW_GET_DATA_SIMPLE and added code to it as necessary to meet the requirements above. It was extracting data fine but the job in ECC was hanging forever and bringing down the server. Then we added the code for RAISE NO_MORE_DATA. Now it is not extracting any data at all. Please help as this is really urgent. Following is the code. pleae tell me what i am doing wrong.
Thanks in advance.
FUNCTION zrsax_get_cd_data .
""Local Interface:
*" IMPORTING
*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL
*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF
*" TABLES
*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*" E_T_DATA STRUCTURE ZDIRUPDTE OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
DataSource tables
TABLES: zdirupdte.
Auxiliary Selection criteria structure
DATA: l_s_select TYPE srsc_s_select.
Maximum number of lines for DB table
STATICS: s_s_if TYPE srsc_s_if_simple,
counter
s_counter_datapakid LIKE sy-tabix,
cursor
s_cursor TYPE cursor.
IF i_initflag = sbiwa_c_flag_on.
Initialization: check input parameters
buffer input parameters
prepare data selection
Check DataSource validity
CASE i_dsource.
WHEN 'Z_DE2110_DIRUPDATE'.
WHEN OTHERS.
IF 1 = 2. MESSAGE e009(r3). ENDIF.
this is a typical log call. Please write every error message like this
log_write 'E' "message type
'R3' "message class
'009' "message number
i_dsource "message variable 1
' '. "message variable 2
RAISE error_passed_to_mess_handler.
ENDCASE.
APPEND LINES OF i_t_select TO s_s_if-t_select.
Fill parameter buffer for data extraction calls
s_s_if-requnr = i_requnr.
s_s_if-dsource = i_dsource.
s_s_if-maxsize = i_maxsize.
APPEND LINES OF i_t_fields TO s_s_if-t_fields.
ELSE. "Initialization mode or data extraction ?
Select: Retrieve all rcords from Custom table, then get CD data.
IF sy-subrc = 0.
LOOP AT payrl_itab. " 1st loop to populate e_t_data with updatd values from custom table.
Add reoord from cusom table. Update with CD header info.
s_counter = s_counter + 1.
MOVE s_counter TO e_t_data-unq_rec_id. "Make record unique
MOVE-CORRESPONDING payrl_itab TO e_t_data.
PERFORM concatenate_key. " key for cdpos_UID
PERFORM select_cd_data. " select CDHDR/CDPOS data
PERFORM get_header_data.
MOVE-CORRESPONDING hdr_itab TO e_t_data.
APPEND e_t_data.
Add same record to datapacket but with old actv/civ type value from CD table.
s_counter = s_counter + 1.
MOVE s_counter TO e_t_data-unq_rec_id.
MOVE-CORRESPONDING payrl_itab TO e_t_data.
MOVE-CORRESPONDING hdr_itab TO e_t_data.
LOOP AT cdpos_itab.
CASE cdpos_itab-fname.
WHEN 'ACTV_TYP'.
MOVE cdpos_itab-value_old TO e_t_data-actv_typ.
WHEN 'CIV_TYP'.
MOVE cdpos_itab-value_old TO e_t_data-civ_typ.
WHEN OTHERS. " Only need ACTV & CIV Types for 1.2.
ENDCASE.
ENDLOOP.
APPEND e_t_data.
CLEAR: hdr_itab[], cdpos_itab[], cdhdr_itab[].
ENDLOOP.
ELSE.
MESSAGE e185.
ENDIF. "First data package
ENDIF.
s_counter_datapakid = s_counter_datapakid + 1.
RAISE NO_MORE_DATA.
ENDIF. "Initialization mode or data extraction ?
ENDFUNCTION.Hi,
Where is the first select statement - that is select statement on the custom table ?
You should open cursor on this table and subsequently fetch package by package.
After each fetch you will check whether any data is retrieved and raise the exception no more data
something like
OPEN CURSOR WITH HOLD s_cursor_doc FOR
SELECT docnr FROM xxxxxx
WHERE racct BETWEEN '0000200000' AND '0000200999'
AND cpudt IN xxxxxx.
ENDIF. "First data package ?
**fetching required PCA documents into ranges table
FETCH NEXT CURSOR s_cursor_doc
INTO TABLE itab_docnr
PACKAGE SIZE s_s_if-maxsize.
IF sy-subrc NE 0.
CLOSE CURSOR s_cursor_doc.
RAISE no_more_data.
ENDIF. -
Sample code for sap hr program--pls treat this as urgent
Hi ,
This is the program on attendence incentive program, i have written
REPORT zhrpa0019 LINE-SIZE 270
LINE-COUNT 55(3)
NO STANDARD PAGE HEADING
MESSAGE-ID zm.
T A B L E S *
TABLES: pernr, pa2001, pa9002.
*Type-pools
TYPE-POOLS slis.
I N F O T Y P E S *
INFOTYPES: 0008, 0001, 0002,2001,9002,0041.
T Y P E S
DATA:BEGIN OF t_data1 OCCURS 0,
pernr LIKE pa0001-pernr,
ename LIKE pa0001-ename,
bukrs LIKE pa0001-bukrs,
werks LIKE pa0001-werks,
btrtl LIKE pa0001-btrtl,
persg LIKE pa0001-persg,
persk LIKE pa0001-persk,
begda LIKE pa0001-begda,
endda LIKE pa0001-endda,
amount LIKE pa0008-bet01,
cdate LIKE pa0041-dat01,
END OF t_data1.
D A T A * Internal table and working area
DATA: i_data1 LIKE t_data1 OCCURS 0 WITH HEADER LINE.
wa_data1 like line of t_data1 .
DATA : BEGIN OF i_date OCCURS 0,
pernr LIKE pa0041-pernr,
cdate LIKE pa0041-dat01,
END OF i_date.
*Data : i_pa0041 like pa0041 occurs 0 with header line,
wa_pa0041 like pa0041.
*Data : i_p0001 like p0001 occurs 0 with header line.
Constants
CONSTANTS: c_102007(6) VALUE '102007',
c_25 TYPE p DECIMALS 1 VALUE '25.0',
c_x VALUE 'X',
c_a value 'A',
c_mcnp(4) value 'MCNP'.
Variables
DATA : v_mvc like pa0008-bet01,
lv_bmonth TYPE char2,
lv_byear TYPE char4,
lv_date TYPE sy-datum.
Parameters Selection
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(31) text-001.
*PARAMETERS:: p_bmonth LIKE pv000-pabrp OBLIGATORY,
p_byear LIKE pv000-pabrj OBLIGATORY.
SELECTION-SCREEN COMMENT 45(10) text-002.
SELECTION-SCREEN END OF LINE.
PARAMETERS: p_mvc(2) TYPE p DECIMALS 1 DEFAULT c_25,
p_mctype TYPE pa2001-awart DEFAULT c_mcnp,
p_ditype TYPE c DEFAULT c_a,
rb_test RADIOBUTTON GROUP grp1 DEFAULT 'X',
rb_prod RADIOBUTTON GROUP grp1.
SELECTION-SCREEN END OF BLOCK b1.
Initialization *
INITIALIZATION.
pnpstat2-low = '3'.
pnpstat2-sign = 'I'.
pnpstat2-option = 'EQ'.
APPEND pnpstat2.
CLEAR pnpstat2.
pnpbukrs-low = 'SATS'.
pnpbukrs-sign = 'I'.
pnpbukrs-option = 'EQ'.
APPEND pnpbukrs.
CLEAR pnpbukrs.
pnppersg-low = 'N'.
pnppersg-sign = 'I'.
pnppersg-option = 'EQ'.
APPEND pnppersg.
CLEAR pnppersg.
pnpbtrtl-low = '2010'.
pnpbtrtl-high = '2050'.
pnpbtrtl-sign = 'I'.
pnpbtrtl-option = 'EQ'.
APPEND pnpbtrtl.
CLEAR pnpbtrtl.
**Clearing the variables
CLEAR : lv_byear, lv_bmonth,
lv_date.
Get previous month from current date
CALL FUNCTION 'CCM_GO_BACK_MONTHS'
EXPORTING
currdate = sy-datum
backmonths = 1
IMPORTING
newdate = lv_date.
lv_byear = lv_date(4).
lv_bmonth = lv_date+4(2).
MOVE lv_bmonth TO p_bmonth.
MOVE lv_byear TO p_byear.
AT Selection-screen *
AT SELECTION-SCREEN.
IF rb_prod = 'X' .
IF sy-uname NP 'HRBTCH*'.
MESSAGE e223(zhpa).
else.
UPDATE pa0015
SET begda = sy-datum
lgart = '216D'
bertg = P_MVC
WHERE pernr = p0001-pernr.
IF SY-SUBRC EQ 0.
message i224(zhpa).
endif.
COMMIT WORK.
ENDIF.
ENDIF.
T O P O F P A G E *
TOP-OF-PAGE.
PERFORM f_top_of_page.
E N D O F P A G E *
END-OF-PAGE.
B E G I N S E L E C T I O N *
START-OF-SELECTION.
GET pernr.
pnp-sw-ignorelockedrecords = 'N'.
PERFORM f_get_hr_data.
E N D S E L E C T I O N *
END-OF-SELECTION.
sort i_data1 by werks ascending
btrtl ascending
persg ascending
persk ascending
pernr ascending.
check for test mode.
if rb_test = 'X'.
clear: i_data1.
loop at i_data1 .
perform f_fill_bdc.
perform f_bdc_transaction using c_pa30.
endloop.
endif.
perform f_display_report.
*& Form f_top_of_page
text
--> p1 text
<-- p2 text
FORM f_top_of_page.
WRITE: text-t11, sy-repid ,
65 text-t12,
150 text-t13,
158 sy-datum.
IF rb_test = c_x.
WRITE:/ text-t21, sy-mandt,
75 text-t22,
150 text-t23,
158 sy-uzeit.
ELSE.
WRITE:/ text-t21, sy-mandt,
117 text-t24,
150 text-t23,
158 sy-uzeit.
ENDIF.
WRITE:/ text-t31, sy-uname,
150 text-t32,
158 sy-pagno.
ULINE.
ENDFORM. " f_top_of_page
*& Form f_get_hr_data
text
--> p1 text
<-- p2 text
FORM f_get_hr_data.
rp-provide-from-last p0001 space pn-begda pn-endda.
IF pnp-sw-found = 1.
PERFORM f_get_data_pa0008.
ENDIF.
ENDFORM. " f_get_hr_data
*& Form f_get_data_pa0008
text
--> p1 text
<-- p2 text
FORM f_get_data_pa0008.
PERFORM f_get_confirm_date.
rp-provide-from-last p0008 space pn-begda pn-endda..
v_mvc = p_mvc.
IF pnp-sw-found = 1.
i_data1-cdate = i_date-cdate.
MOVE p0001-pernr TO i_data1-pernr.
MOVE p0001-ename TO i_data1-ename.
MOVE p0001-werks TO i_data1-werks.
MOVE p0001-btrtl TO i_data1-btrtl.
MOVE p0001-persg TO i_data1-persg.
MOVE p0001-bukrs TO i_data1-bukrs.
MOVE p0001-persk TO i_data1-persk.
MOVE i_date-cdate TO i_data1-cdate.
MOVE v_mvc TO i_data1-amount.
APPEND i_data1.
CLEAR i_data1.
ENDIF.
ENDFORM. " f_get_data_pa0008
*& Form f_display_report
text
--> p1 text
<-- p2 text
FORM f_display_report.
perform alv_display.
*Output to a list
data : lv_stotal(5) type n,
lv_utotal(5) type n,
lv_format.
constants : c_l value '|'.
clear: i_data1.
format color col_total intensified on.
write: /, / 'Successfully Updated to Database:'.
write: /.
format reset.
uline (200).
format color col_heading intensified off.
write : /1 c_l no-gap, (8) 'Pnumber' no-gap,
c_l no-gap, (35) 'Name' no-gap,
c_l no-gap, (5) 'PA' no-gap,
c_l no-gap, (5) 'PSA' no-gap,
c_l no-gap, (6) 'EE Grp' no-gap,
c_l no-gap, (9) 'EE Subgrp' no-gap,
c_l no-gap, (12) 'Amount' no-gap,
200 c_l.
uline (200).
format reset.
loop at i_data1 .
perform f_format_amount.
if lv_format = 'X'.
clear lv_format.
format color col_normal intensified off.
else.
lv_format = 'X'.
format color col_normal intensified on.
endif.
write :/1 c_l no-gap, (8) i_data1-pernr no-gap,
c_l no-gap, (35) i_data1-ename no-gap,
c_l no-gap, (5) i_data1-werks no-gap,
c_l no-gap, (5) i_data1-btrtl no-gap,
c_l no-gap, (6) i_data1-persg no-gap,
c_l no-gap, (9) i_data1-persk no-gap,
c_l no-gap , (12) i_data1-amount no-gap.
endloop.
ENDFORM . "f_display_report
*& Form get_confirm_date
text
--> p1 text
<-- p2 text
FORM f_get_confirm_date .
rp-provide-from-last p0041 space pn-begda pn-endda.
IF pnp-sw-found = 1.
CLEAR i_date.
i_date-pernr = p0041-pernr.
APPEND i_date.
PERFORM f_populate_date USING : p0041-pernr
p0041-dar01 p0041-dat01,
p0041-pernr
p0041-dar02 p0041-dat02,
p0041-pernr
p0041-dar03 p0041-dat03,
p0041-pernr
p0041-dar04 p0041-dat04,
p0041-pernr
p0041-dar05 p0041-dat05,
p0041-pernr
p0041-dar06 p0041-dat06,
p0041-pernr
p0041-dar07 p0041-dat07,
p0041-pernr
p0041-dar08 p0041-dat08,
p0041-pernr
p0041-dar09 p0041-dat09,
p0041-pernr
p0041-dar10 p0041-dat10,
p0041-pernr
p0041-dar11 p0041-dat11,
p0041-pernr
p0041-dar12 p0041-dat12.
ENDIF.
ENDFORM. " get_confirm_date
*& Form f_populate_date
text
-->P_PERNR text
-->P_DAR text
-->P_DAT text
FORM f_populate_date USING p_pernr p_dar p_dat.
CLEAR i_date.
READ TABLE i_date WITH KEY pernr = p_pernr.
IF sy-subrc = 0.
IF p_dar = 'A3'.
i_date-cdate = p_dat.
MODIFY i_date INDEX sy-tabix.
ENDIF.
ENDIF.
endform.
i need to add the logic , could you pls help as this is very urgent.........
IF test run = X
Display the report
IF production run = X
1. Batch user ID HRBTCH* performed the execution.
Create new record based on the following parameters:
- PA0015-BEGDA = System Date (date of origin)
- PA0015-LGART = 216D (wage type)
- PA0015-BETRG = IAP amount (25)
Display the report.
2. Program was not executed by Batch user ID HRBTCH*
Display information message Only batch user ID can run actual mode.
Display the report
No update will be done.
ENDIF.
how to addd in the above code.....REPORT ZHR_ATTENDANCE_RPT MESSAGE-ID ZHR.
T Y P E P O O L S *
TYPE-POOLS : SLIS.
T A B L E *
TABLES : TEVEN,
PA0000,
PA0001,
T503K,
T500P.
I N T E R N A L T A B L E D E C L A R A T I O N *
DATA : BEGIN OF IT_PA0001 OCCURS 0,
PERNR TYPE PA0001-PERNR,
ENDDA TYPE PA0001-ENDDA,
WERKS TYPE PA0001-WERKS,
BTRTL TYPE PA0001-BTRTL,
ORGEH TYPE PA0001-ORGEH,
PERSK TYPE T503T-PERSK,
ENAME TYPE PA0001-ENAME,
END OF IT_PA0001.
DATA : BEGIN OF IT_PA0000 OCCURS 0,
PERNR TYPE PA0000-PERNR,
END OF IT_PA0000.
DATA : BEGIN OF IT_TEVEN OCCURS 0,
PERNR TYPE TEVEN-PERNR,
LDATE TYPE TEVEN-LDATE,
LTIME TYPE TEVEN-LTIME,
SATZA TYPE TEVEN-SATZA,
END OF IT_TEVEN.
DATA : IT_TEVEN1 LIKE IT_TEVEN OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF IT_T527X OCCURS 0,
ORGEH LIKE T527X-ORGEH,
ORGTX LIKE T527X-ORGTX,
END OF IT_T527X.
DATA : BEGIN OF IT_T503T OCCURS 0,
PERSK TYPE T503T-PERSK,
PTEXT TYPE T503T-PTEXT,
END OF IT_T503T.
DATA : BEGIN OF IT_FINAL OCCURS 0,
PERNR LIKE PA0001-PERNR,
ENAME LIKE PA0001-ENAME,
LDATE LIKE TEVEN-LDATE,
TPROG LIKE PTPSP-TPROG,
LTIMEI LIKE TEVEN-LTIME,
LTIMEO LIKE TEVEN-LTIME,
ORGTX LIKE T527X-ORGTX,
PTEXT TYPE T503T-PTEXT,
ATEXT TYPE ABWTXT,
END OF IT_FINAL.
DATA : IT_PTPSP LIKE PTPSP OCCURS 0 WITH HEADER LINE.
*Table to get Holiday
DATA : IT_ISCAL_DAY LIKE ISCAL_DAY OCCURS 0 WITH HEADER LINE.
DATA : IT_T554T TYPE T554T OCCURS 0 WITH HEADER LINE.
*ALV data declarations
DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,
X_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
GD_REPID LIKE SY-REPID.
*For ALV Events
DATA : IT_EVENT1 TYPE SLIS_T_EVENT.
*For ALV Events
DATA : IT_EVENT TYPE SLIS_ALV_EVENT.
*For ALV top of page
DATA : IT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
*For top of page heading
DATA : IT_LINE TYPE SLIS_LISTHEADER.
Variables declaration *
DATA : V_SHIFT LIKE PTPSP-TPROG,
V_TEMP TYPE I,
V_DATE TYPE DATUM,
V_LDATE TYPE SY-DATUM,
V_MODIF TYPE HIDENT,
V_SUBTY TYPE PA2002-SUBTY,
V_ENDDA TYPE CHAR10.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_PERNR FOR TEVEN-PERNR,
S_DATE FOR TEVEN-LDATE no-extension,
S_ORGEH FOR PA0001-ORGEH,
S_WERKS FOR PA0001-WERKS,
S_BTRTL FOR PA0001-BTRTL,
S_PERSK FOR PA0001-PERSK,
S_STAT2 FOR PA0000-STAT2.
SELECTION-SCREEN END OF BLOCK B1.
A T S E L E C T I O N S C R E E N *
*validatating Selection Screen
AT SELECTION-SCREEN ON S_PERNR.
*Validate the User entered year
PERFORM VALIDATE_PERNR.
AT SELECTION-SCREEN ON S_DATE.
*Validate the User entered date
PERFORM VALIDATE_DATE_LOW.
AT SELECTION-SCREEN ON S_ORGEH.
*Validate the User entered year
PERFORM VALIDATE_ORGEH.
AT SELECTION-SCREEN ON S_PERSK.
*Validate the User entered year
PERFORM VALIDATE_PERSK.
AT SELECTION-SCREEN ON S_WERKS.
*Validate the User entered Personnel area
PERFORM VALIDATE_WERKS.
START OF SELECTION *
START-OF-SELECTION.
*Get data
PERFORM GET_DATA.
*Process data
PERFORM PROCESS_DATA.
E N D O F S E L E C T I O N *
END-OF-SELECTION.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
*For ALV Events
PERFORM ALV_EVENTS.
PERFORM DISPLAY_ALV_REPORT.
*& Form VALIDATE_YEAR
Validating the year
FORM VALIDATE_PERNR .
IF NOT S_PERNR IS INITIAL.
SELECT SINGLE * FROM PA0001 WHERE PERNR IN S_PERNR. "#EC *
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Enter valid Employee Number'(002).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_pernr
*& Form VALIDATE_YEAR
Validating the year
FORM VALIDATE_ORGEH .
DATA: V_ORGEH LIKE T527X-ORGEH.
IF NOT S_ORGEH IS INITIAL.
SELECT SINGLE ORGEH FROM T527X INTO V_ORGEH WHERE ORGEH IN S_ORGEH.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Enter Valid Organization Unit'(003).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_orgeh
*& Form GET_DATA
Get data
FORM GET_DATA.
SELECT PERNR
FROM PA0000
INTO TABLE IT_PA0000
WHERE PERNR IN S_PERNR
AND ENDDA GE S_DATE-LOW
AND BEGDA LE S_DATE-HIGH
AND STAT2 IN S_STAT2.
IF SY-SUBRC = 0.
DELETE ADJACENT DUPLICATES FROM IT_PA0000 COMPARING PERNR.
SORT IT_PA0000.
ENDIF.
IF NOT IT_PA0000[] IS INITIAL.
SELECT PERNR
ENDDA
WERKS
BTRTL
ORGEH
PERSK
ENAME
FROM PA0001
INTO TABLE IT_PA0001
FOR ALL ENTRIES IN IT_PA0000
WHERE PERNR = IT_PA0000-PERNR
AND ENDDA GE S_DATE-LOW
AND BEGDA LE S_DATE-HIGH
AND ORGEH IN S_ORGEH
AND WERKS IN S_WERKS
AND PERSK IN S_PERSK
AND BTRTL IN S_BTRTL.
IF SY-SUBRC = 0.
SORT IT_PA0001 BY PERNR ENDDA DESCENDING.
DELETE ADJACENT DUPLICATES FROM IT_PA0001 COMPARING PERNR.
SORT IT_PA0001 BY PERNR.
ENDIF.
ENDIF.
IF NOT IT_PA0001[] IS INITIAL.
SELECT PERNR
LDATE
LTIME
SATZA
FROM TEVEN
INTO TABLE IT_TEVEN
FOR ALL ENTRIES IN IT_PA0001
WHERE PERNR = IT_PA0001-PERNR
AND SATZA = 'P10'
AND LDATE IN S_DATE
AND STOKZ NE 'X'.
IF SY-SUBRC = 0.
SORT IT_TEVEN BY PERNR LDATE.
ENDIF.
ENDIF.
IF NOT IT_PA0001[] IS INITIAL.
v_date = s_date-high + 1.
SELECT PERNR
LDATE
LTIME
SATZA
FROM TEVEN
INTO TABLE IT_TEVEN1
FOR ALL ENTRIES IN IT_PA0001
WHERE PERNR = IT_PA0001-PERNR
AND SATZA = 'P20'
AND ( LDATE IN S_DATE or ldate = v_date )
AND STOKZ NE 'X'.
IF SY-SUBRC = 0.
SORT IT_TEVEN1 BY PERNR LDATE.
ENDIF.
ENDIF.
IF NOT IT_PA0001[] IS INITIAL.
SELECT ORGEH
ORGTX
FROM T527X
INTO TABLE IT_T527X
FOR ALL ENTRIES IN IT_PA0001
WHERE ORGEH = IT_PA0001-ORGEH.
IF SY-SUBRC = 0.
SORT IT_T527X BY ORGEH.
ENDIF.
ENDIF.
IF NOT IT_PA0001[] IS INITIAL.
SELECT PERSK
PTEXT
FROM T503T
INTO TABLE IT_T503T
FOR ALL ENTRIES IN IT_PA0001
WHERE PERSK = IT_PA0001-PERSK
AND SPRSL = 'E'.
IF SY-SUBRC = 0.
SORT IT_T503T BY PERSK.
ENDIF.
ENDIF.
SELECT *
FROM T554T
INTO TABLE IT_T554T
WHERE SPRSL = 'EN'
AND MOABW = '40'.
ENDFORM. " GET_DATA
*& Form PROCESS_DATA
Process data
FORM PROCESS_DATA .
V_TEMP = S_DATE-HIGH - S_DATE-LOW.
V_TEMP = V_TEMP + 1.
LOOP AT IT_PA0001.
V_DATE = S_DATE-LOW.
DO V_TEMP TIMES.
*Get employee work schedule
IF IT_PTPSP[] IS INITIAL.
PERFORM GET_SCHEDULE.
ENDIF.
*Get holiday calendar
IF IT_ISCAL_DAY[] IS INITIAL.
PERFORM GET_HOLIDAY.
ENDIF.
CLEAR : V_SUBTY.
SELECT SINGLE SUBTY
FROM PA2001
INTO V_SUBTY
WHERE PERNR = IT_PA0001-PERNR
AND ENDDA GE V_DATE
AND BEGDA LE V_DATE.
IF SY-SUBRC = 0.
READ TABLE IT_T554T WITH KEY AWART = V_SUBTY.
IT_FINAL-ATEXT = IT_T554T-ATEXT.
ENDIF.
IF V_SUBTY IS INITIAL.
SELECT SINGLE SUBTY
FROM PA2002
INTO V_SUBTY
WHERE PERNR = IT_PA0001-PERNR
AND ENDDA GE V_DATE
AND BEGDA LE V_DATE.
IF SY-SUBRC = 0.
IF V_SUBTY = '1000' OR V_SUBTY = '2000'.
IT_FINAL-ATEXT = 'Training'.
ELSEIF V_SUBTY = '3000'.
IT_FINAL-ATEXT = 'Tour'.
ENDIF.
ENDIF.
ENDIF.
*Get the employee shift schedule for that date
CLEAR : V_SHIFT.
READ TABLE IT_PTPSP WITH KEY DATUM = V_DATE.
IF SY-SUBRC = 0.
V_SHIFT = IT_PTPSP-TPROG.
IF IT_PTPSP-TAGTY = '1'.
V_SHIFT = 'NOFF'.
ENDIF.
ENDIF.
IF V_SHIFT = ''.
CLEAR IT_FINAL.
CONTINUE.
ENDIF.
*Check for holiday
IT_FINAL-TPROG = V_SHIFT.
READ TABLE IT_ISCAL_DAY WITH KEY DATE = V_DATE.
IF SY-SUBRC = 0.
IT_FINAL-TPROG = 'H'.
ENDIF.
IT_FINAL-PERNR = IT_PA0001-PERNR.
IT_FINAL-ENAME = IT_PA0001-ENAME.
IT_FINAL-LDATE = V_DATE.
*To get the organization unit
READ TABLE IT_T527X WITH KEY ORGEH = IT_PA0001-ORGEH
BINARY SEARCH.
IF SY-SUBRC = 0.
IT_FINAL-ORGTX = IT_T527X-ORGTX.
ENDIF.
CLEAR IT_T503T.
READ TABLE IT_T503T WITH KEY PERSK = IT_PA0001-PERSK
BINARY SEARCH.
IF SY-SUBRC = 0.
IT_FINAL-PTEXT = IT_T503T-PTEXT.
ENDIF.
V_LDATE = v_DATE + 1.
*To get Punch-in.
READ TABLE IT_TEVEN WITH KEY PERNR = IT_PA0001-PERNR
LDATE = V_DATE
BINARY SEARCH.
IF SY-SUBRC = 0.
IT_FINAL-LTIMEI = IT_TEVEN-LTIME.endif.
*To get Punch-out
READ TABLE IT_TEVEN1 WITH KEY PERNR = IT_PA0001-PERNR
LDATE = v_DATE
BINARY SEARCH.
IF SY-SUBRC = 0.
IF IT_TEVEN1-LTIME > IT_FINAL-LTIMEI.
IT_FINAL-LTIMEO = IT_TEVEN1-LTIME.
ELSE.
SELECT SINGLE LTIME
FROM TEVEN
INTO IT_FINAL-LTIMEO
WHERE PERNR = IT_PA0001-PERNR
AND LDATE = v_DATE
AND LTIME > IT_TEVEN1-LTIME
AND SATZA = 'P20'
AND STOKZ NE 'X'.
ENDIF.
ENDIF.
IF IT_FINAL-LTIMEO IS INITIAL.
IF V_SHIFT = 'NNIG' OR V_SHIFT = 'NAFT'..
READ TABLE IT_TEVEN1 WITH KEY PERNR = IT_PA0001-PERNR
LDATE = V_LDATE
BINARY SEARCH.
IF SY-SUBRC = 0.
IT_FINAL-LTIMEO = IT_TEVEN1-LTIME.
ENDIF.
ENDIF.
ENDIF.
if ( V_SHIFT = 'NOFF' OR IT_FINAL-TPROG = 'H' )
and it_final-ltimei is initial and it_final-ltimeo is not initial.
clear: it_final-ltimeo.endif.
APPEND IT_FINAL.
ELSE.
*If holiday or OFF or Tour or Absent
IF V_SHIFT = 'NOFF' OR IT_FINAL-TPROG = 'H'
or it_final-atext is not initial or
( it_final-ltimei is not initial and it_final-ltimeo is not initial ).
APPEND IT_FINAL.
ELSEIF IT_FINAL-ATEXT IS NOT INITIAL.
APPEND IT_FINAL.
ELSE.
IT_FINAL-ATEXT = 'Absent'.
APPEND IT_FINAL.
ENDIF.
ENDIF.
APPEND IT_FINAL.
CLEAR : IT_FINAL.
V_DATE = V_DATE + 1.
ENDDO.
CLEAR : IT_PTPSP[],
IT_ISCAL_DAY[].
ENDLOOP.
SORT IT_FINAL BY PERNR LDATE.
LOOP AT IT_FINAL.
TRANSLATE IT_FINAL-ATEXT TO UPPER CASE.
MODIFY IT_FINAL INDEX SY-TABIX.
ENDLOOP.
ENDFORM. " PROCESS_DATA
*& Form GET_SCHEDULE
Get employee work schedule
FORM GET_SCHEDULE.
CALL FUNCTION 'HR_PERSONAL_WORK_SCHEDULE'
EXPORTING
PERNR = IT_PA0001-PERNR
BEGDA = S_DATE-LOW
ENDDA = S_DATE-HIGH
TABLES
PERWS = IT_PTPSP
EXCEPTIONS
ERROR_OCCURED = 1
ABORT_OCCURED = 2
OTHERS = 3.
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. " GET_SCHEDULE
*& Form build_fieldcatalog
FORM BUILD_FIELDCATALOG .
X_FIELDCATALOG-COL_POS = 1.
X_FIELDCATALOG-FIELDNAME = 'PERNR'.
X_FIELDCATALOG-SELTEXT_L = 'Personnel No'(006).
X_FIELDCATALOG-DDICTXT = 'L'.
APPEND X_FIELDCATALOG TO FIELDCATALOG.
CLEAR X_FIELDCATALOG.
X_FIELDCATALOG-COL_POS = 2.
X_FIELDCATALOG-FIELDNAME = 'ENAME'.
X_FIELDCATALOG-SELTEXT_L = 'Employee Name'(007).
X_FIELDCATALOG-DDICTXT = 'L'.
APPEND X_FIELDCATALOG TO FIELDCATALOG.
CLEAR X_FIELDCATALOG.
X_FIELDCATALOG-COL_POS = 5.
X_FIELDCATALOG-FIELDNAME = 'LDATE'.
X_FIELDCATALOG-SELTEXT_L = 'Date'(008).
X_FIELDCATALOG-DDICTXT = 'L'.
APPEND X_FIELDCATALOG TO FIELDCATALOG.
CLEAR X_FIELDCATALOG.
X_FIELDCATALOG-COL_POS = 6.
X_FIELDCATALOG-FIELDNAME = 'TPROG'.
X_FIELDCATALOG-SELTEXT_L = 'Planned Shift'(009).
X_FIELDCATALOG-DDICTXT = 'L'.
APPEND X_FIELDCATALOG TO FIELDCATALOG.
CLEAR X_FIELDCATALOG.
X_FIELDCATALOG-COL_POS = 7.
X_FIELDCATALOG-FIELDNAME = 'LTIMEI'.
X_FIELDCATALOG-SELTEXT_L = 'Attended Time-In'(010).
X_FIELDCATALOG-DDICTXT = 'L'.
APPEND X_FIELDCATALOG TO FIELDCATALOG.
CLEAR X_FIELDCATALOG.
X_FIELDCATALOG-COL_POS = 8.
X_FIELDCATALOG-FIELDNAME = 'LTIMEO'.
X_FIELDCATALOG-SELTEXT_L = 'Attended Time-Out'(011).
X_FIELDCATALOG-DDICTXT = 'L'.
APPEND X_FIELDCATALOG TO FIELDCATALOG.
CLEAR X_FIELDCATALOG.
X_FIELDCATALOG-COL_POS = 3.
X_FIELDCATALOG-FIELDNAME = 'ORGTX'.
X_FIELDCATALOG-SELTEXT_L = 'Organization Unit'(005).
X_FIELDCATALOG-DDICTXT = 'L'.
APPEND X_FIELDCATALOG TO FIELDCATALOG.
CLEAR X_FIELDCATALOG.
X_FIELDCATALOG-COL_POS = 4.
X_FIELDCATALOG-FIELDNAME = 'PTEXT'.
X_FIELDCATALOG-SELTEXT_L = 'Emp Subgroup'(016).
X_FIELDCATALOG-DDICTXT = 'L'.
APPEND X_FIELDCATALOG TO FIELDCATALOG.
CLEAR X_FIELDCATALOG.
X_FIELDCATALOG-COL_POS = 9.
X_FIELDCATALOG-FIELDNAME = 'ATEXT'.
X_FIELDCATALOG-SELTEXT_L = 'Leaves/Tours'(015).
X_FIELDCATALOG-DDICTXT = 'L'.
X_FIELDCATALOG-OUTPUTLEN = '25'.
APPEND X_FIELDCATALOG TO FIELDCATALOG.
CLEAR X_FIELDCATALOG.
ENDFORM. " build_fieldcatalog
*& Form build_layout
FORM BUILD_LAYOUT.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-ZEBRA = 'X'.
ENDFORM. " build_layout
*& Form ALV_EVENTS
For ALV Events
FORM ALV_EVENTS .
IT_EVENT-NAME = 'TOP_OF_PAGE'.
IT_EVENT-FORM = 'TOP_OF_PAGE'.
APPEND IT_EVENT TO IT_EVENT1.
ENDFORM. " ALV_EVENTS
*& Form TOP_OF_PAGE
ALV TOP-OF-PAGE
FORM TOP_OF_PAGE. "#EC CALLED
REFRESH : IT_LIST_TOP_OF_PAGE.
CLEAR : IT_LINE.
IT_LINE-TYP = 'H'.
IT_LINE-INFO = 'Attendance Report for the Period'(013).
APPEND IT_LINE TO IT_LIST_TOP_OF_PAGE.
CONCATENATE S_DATE-LOW6(2) '.' S_DATE-LOW4(2) '.' S_DATE-LOW+0(4)
INTO IT_LINE-INFO.
CONCATENATE S_DATE-HIGH6(2) '.' S_DATE-HIGH4(2) '.' S_DATE-HIGH+0(4) INTO V_ENDDA.
CONCATENATE IT_LINE-INFO '-' V_ENDDA INTO IT_LINE-INFO SEPARATED BY SPACE.
APPEND IT_LINE TO IT_LIST_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LIST_TOP_OF_PAGE.
ENDFORM. "TOP_OF_PAGE
*& Form display_alv_report
FORM DISPLAY_ALV_REPORT.
GD_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GD_REPID
IT_EVENTS = IT_EVENT1
IS_LAYOUT = GD_LAYOUT
IT_FIELDCAT = FIELDCATALOG
TABLES
T_OUTTAB = IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "display_alv_report
*& Form VALIDATE_PERSK
text
--> p1 text
<-- p2 text
FORM VALIDATE_PERSK .
IF NOT S_PERSK IS INITIAL.
SELECT SINGLE * FROM T503K WHERE PERSK IN S_PERSK. "#EC *
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Enter valid Employee subgroup'(012).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_PERSK
*& Form VALIDATE_WERKS
Validate user Entered Personnel area
FORM VALIDATE_WERKS .
IF S_WERKS[] IS NOT INITIAL.
SELECT SINGLE * FROM T500P WHERE PERSA IN S_WERKS.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Enter valid Personnel Area'(014).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_WERKS
*& Form VALIDATE_DATE_LOW
Validate user Entered Date
FORM VALIDATE_DATE_LOW .
IF S_DATE-LOW IS INITIAL.
MESSAGE E000 WITH 'Enter Date'(004).
ENDIF.
IF S_DATE-HIGH IS INITIAL.
MESSAGE E000 WITH 'Enter Date'(004).
ENDIF.
ENDFORM. " VALIDATE_DATE_LOW
*& Form GET_HOLIDAY
Get Holiday
FORM GET_HOLIDAY .
CLEAR V_MODIF.
SELECT SINGLE MOFID
FROM T001P
INTO V_MODIF
WHERE WERKS = IT_PA0001-WERKS
AND BTRTL = IT_PA0001-BTRTL.
CALL FUNCTION 'HOLIDAY_GET'
EXPORTING
HOLIDAY_CALENDAR = V_MODIF
DATE_FROM = S_DATE-LOW
DATE_TO = S_DATE-HIGH
TABLES
HOLIDAYS = IT_ISCAL_DAY
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 1
HOLIDAY_CALENDAR_NOT_FOUND = 2
DATE_HAS_INVALID_FORMAT = 3
DATE_INCONSISTENCY = 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.
ENDFORM. " GET_HOLIDAY
<b>Reward Points if useful.</b> -
hi gurus,
i have a problem in bdc programm there is 3 screen using transaction f-27
there is two amount field as(wrbtr,wrbtr2)
two screen are run fine but the 3 screen does't take data automatically from flat file plz help me its urgent see my codes and give me solution.
TYPES: BEGIN OF it_output,
bldat(10) TYPE C, "Document Date
blart TYPE bkpf-blart, "Document Type
bukrs TYPE bkpf-bukrs, "Company Code
budat(10) TYPE C, "Posting Date
monat TYPE bkpf-monat, "Period
waers TYPE bkpf-waers, "Currency
xblnr TYPE bkpf-xblnr, "Reference Field
docid TYPE fs006-docid, "Document ID
newbs TYPE rf05a-newbs, "Posting Key
newko TYPE rf05a-newko, "Account Code
wrbtr(16) TYPE C, "Amount in Document currency
zfbdt(10) TYPE C, "Baseline Date
newbs2 TYPE rf05a-newbs, "Account Key2
newko2 TYPE rf05a-newko, "Account code2
wrbtr2(16) TYPE C, "Amount2
END OF it_output.
DATA lt_output TYPE it_output OCCURS 0 WITH HEADER LINE.
DATA it_bdc LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA it_messtab LIKE bdcmsgcoll OCCURS 1 WITH HEADER LINE.
D A T A *
DATA: message TYPE string.
DATA: p_file1 type string.
S E L E C T - O P T I O N S / P A R A M E T E R S *
SELECTION-SCREEN BEGIN OF BLOCK block0 WITH FRAME.
PARAMETERS : p_file LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK block0.
A T S E L E C T I O N - S C R E E N *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
mask = space
CHANGING
file_name = p_file.
S T A R T - O F - S E L E C T I O N
START-OF-SELECTION.
PERFORM upload.
PERFORM bdc.
PERFORM write_message.
*& Form bdc
text
FORM bdc.
LOOP AT lt_output.
READ TABLE lt_output INDEX 1.
PERFORM bdc_dynpro USING 'SAPMF05A' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR' 'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'BKPF-BLDAT' lt_output-bldat.
PERFORM bdc_field USING 'BKPF-BLART' lt_output-blart.
PERFORM bdc_field USING 'BKPF-BUKRS' lt_output-bukrs.
PERFORM bdc_field USING 'BKPF-BUDAT' lt_output-budat.
PERFORM bdc_field USING 'BKPF-MONAT' lt_output-monat.
PERFORM bdc_field USING 'BKPF-WAERS' lt_output-waers.
PERFORM bdc_field USING 'BKPF-XBLNR' lt_output-xblnr.
PERFORM bdc_field USING 'FS006-DOCID' lt_output-docid.
PERFORM bdc_field USING 'RF05A-NEWBS' lt_output-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO' lt_output-newko.
PERFORM bdc_dynpro USING 'SAPMF05A' '0302'.
PERFORM bdc_field USING 'BDC_CURSOR' 'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'BSEG-WRBTR' lt_output-wrbtr.
PERFORM bdc_field USING 'BSEG-ZFBDT' lt_output-zfbdt.
PERFORM bdc_field USING 'RF05A-NEWBS' lt_output-newbs2."newbs2
PERFORM bdc_field USING 'RF05A-NEWKO' lt_output-newko2."newko2
PERFORM bdc_dynpro USING 'SAPMF05A' '0301'.
PERFORM bdc_field USING 'BDC_CURSOR' 'BSEG-WRBTR'.
PERFORM bdc_field USING 'BDC_OKCODE' '=BU'.
PERFORM bdc_field USING 'BSEG-WRBTR' lt_output-wrbtr2."wrbtr2
PERFORM bdc_field USING 'BSEG-MWSKZ' '**'.
PERFORM bdc_field USING 'BSEG-ZTERM' 'C007'.
PERFORM bdc_field USING 'BSEG-ZBD1T' '7'.
CALL TRANSACTION 'F-27' USING it_bdc mode 'A'
MESSAGES INTO it_messtab.
CLEAR it_bdc. REFRESH it_bdc.
ENDLOOP.
ENDFORM. "bdc
*& Form write_message
text
FORM write_message.
LOOP AT it_messtab .
CLEAR message.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
lang = 'EN'
no = sy-msgno
v1 = sy-msgv1
v2 = sy-msgv2
v3 = sy-msgv3
v4 = sy-msgv4
IMPORTING
msg = message.
CASE it_messtab-msgtyp.
WHEN 'S'.
WRITE:/ message.
CLEAR message.
WHEN 'E'.
FORMAT COLOR 6 ON.
WRITE:/ message.
CLEAR message.
ENDCASE.
ENDLOOP.
ENDFORM. "write_message
FORM BDC_DYNPRO *
--> PROGRAM *
--> DYNPRO *
FORM bdc_dynpro USING program dynpro.
it_bdc-program = program.
it_bdc-dynpro = dynpro.
it_bdc-dynbegin = 'X'.
APPEND it_bdc.
CLEAR it_bdc.
ENDFORM. "BDC_DYNPRO
FORM *
FORM bdc_field USING fnam fval.
it_bdc-fnam = fnam.
it_bdc-fval = fval.
APPEND it_bdc.
CLEAR it_bdc.
ENDFORM. "BDC_FIELD
*& Form upload
text
--> p1 text
<-- p2 text
FORM upload .
p_file1 = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file1
FILETYPE = 'DAT'
tables
data_tab = lt_output
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
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. " upload
i am also send u my flat file the client says that in amount filed of 3rd screen we will give the * asterick or other amount plz take it.
thank
plz help me.
jay
Edited by: jayant kumar on Apr 30, 2008 12:42 PMhi jayant,
Declare '**' as a character constant and pass this constant to the Subroutine.
data : c_astrick type char2 value '**'.
PERFORM bdc_field USING 'BSEG-MWSKZ c_astrick.
Reward points if it is helpful.
Regards,
srilatha. -
Urgent: Problems in Generic Extraction by Function Module
Hi BW Gurus,
I am new to SDN and also new to generic extraction using function module. My requirement is to extract long text(142 char) from CRM to BW as the text is not stored in database table I used function module read_text with in another ZXXX function module copy of (RSAX_BIW_GET_DATA_SIMPLE). In my extract structure I used GUID(char,32), Langu, long text(142 char) and 2 placeholders. Text can be extracted by passing STXH table fields(Tdname, Tdid, Tdobject, Tdspars) to read_text as parameters and i also need to use CRMD_ORDERADM_H field GUID(32 char) to compare 1st 32 chars of tdname(70 char) with Guid to select Guids and loop thru this Guids and for each Guid i need to append lines of text to e_t_data but as i donot know ABAP i unable to write the code for this. Through my friends help i wrote code when i check in RSA3 it is displaying the text but when i replicate into BW and load into data target in monitor the status is red with records initially but afterwards it will be red status again with 0 from 0 records for initial load again.when i check on job logs the errors i have are:
The background job has created a job log file of 2Gb size and it is currently on a infinite loop writing entries into the SAP System Log that it cannot write to the Job log file due to Error 22 for write/read access to a file this is because of the datasource i have created. Please find my Function module and if anyone would please correct FM and send me that will be really great.I appreciate it in advance.
MY Function Module is:
FUNCTION Z_CRMORDERH_STR_TXT.
""Local Interface:
*" IMPORTING
*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL
*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF
*" TABLES
*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*" E_T_DATA STRUCTURE YCRM_TEXT_STR OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
***" EXCEPTIONS NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
Tables: CRMD_ORDERADM_H, STXH.
Auxiliary Selection criteria structure
data: l_s_select type srsc_s_select.
Maximum number of lines for DB table
Statics: s_s_if type srsc_s_if_simple,
counter
s_counter_datapakid like sy-tabix,
Cursor
s_cursor type cursor.
data: i_crmtext type standard table of TLINE .
types: begin of xsreph ,
GUID type CRMD_ORDERADM_H-guid,
end of xsreph.
data: i_guid type standard table of xsreph.
data: I_TEXT type STXH-TDNAME.
data: xempl like YCRM_TEXT_STR occurs 0 with header line.
data: t_tab like dd03l-tabname.
Select ranges
ranges: l_r_guid for CRMD_ORDERADM_H-guid.
l_r_connid for sflight-connid.
Initialization mode (first call by SAPI) or data transfer mode
(following calls) ?
if i_initflag = sbiwa_c_flag_on.
Initialization: check input parameters
buffer input parameters
prepare data selection
Check DataSource validity
case i_dsource.
when 'yCRM_TEXT'. " for S_SREPH1
when others.
if 1 = 2. message e009(r3). endif.
this is a typical log call. Please write every error message like this
log_write 'E' "message type
'R3' "message class
'009' "message number
i_dsource "message variable 1
' '. "message variable 2
raise error_passed_to_mess_handler.
endcase.
append lines of i_t_select to s_s_if-t_select.
Fill parameter buffer for data extraction calls
s_s_if-requnr = i_requnr.
s_s_if-dsource = i_dsource.
s_s_if-maxsize = i_maxsize.
Fill field list table for an optimized select statement
(in case that there is no 1:1 relation between InfoSource fields
and database table fields this may be far from beeing trivial)
append lines of i_t_fields to s_s_if-t_fields.
we will do our selection based on what is in the p table for the
infoobject
else. "Initialization mode or data extraction ?
Data transfer: First Call OPEN CURSOR + FETCH
Following Calls FETCH only
First data package -> OPEN CURSOR
if s_counter_datapakid = 0.
Fill range tables BW will only pass down simple selection criteria
of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'GUID'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_GUID.
APPEND L_R_GUID.
ENDLOOP.
case i_dsource.
when 'YCRM_TEXT'. " for S_SREPH1
t_tab = 'CRMD_ORDERADM_H'.
endcase.
select GUID
from (t_tab)
into table i_guid where PROCESS_TYPE = 'ZACI' and ( OBJECT_ID < '0000000042').
select tdname from stxh into i_text where tdobject = 'TEXT'.
if sy-subrc ne 0.
message e009(r3).
this is a typical log call. Please write every error message like this
log_write 'E' "message type
'R3' "message class
'009' "message number
i_dsource "message variable 1
'No master data found'. "message variable 2
raise error_passed_to_mess_handler.
endif.
Determine number of database records to be read per FETCH statement
from input parameter I_MAXSIZE. If there is a one to one relation
between DataSource table lines and database entries, this is trivial.
In other cases, it may be impossible and some estimated value has to
be determined.
open cursor with hold s_cursor for
select (s_s_if-t_fields) from CRMD_ORDERADM_H
where GUID in L_R_GUID .
ENDIF.
Fetch records into interface table.
named E_T_'Name of extract structure'.
fetch next cursor s_cursor
appending corresponding fields
of table e_t_data
package size s_s_if-maxsize.
IF SY-SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.
ENDIF.
as we are doing this only once can use the select statement.
***data: crmtext like tline occurs 0 with header line.
**data: i_crmtext type standard table of TLINE.
**data: i_guid type standard table of xsreph.
data: l_guid type THEAD-TDNAME.
data: st_guid type xsreph.
data: st_crmtext type TLINE.
data: lan type THEAD-TDSPRAS.
lan = 'E'.
loop at i_guid into st_guid.
l_guid = st_guid-guid.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'A002'
LANGUAGE = lan
NAME = l_guid
OBJECT = 'CRM_ORDERH'
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
TABLES
LINES = i_crmtext.
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
e_t_data-guid = l_guid.
loop at i_crmtext into st_crmtext.
move lan to e_t_data-langu.
move st_crmtext-tdline to e_t_data-description.
append e_t_data.
endif.
endloop.
clear: st_guid,l_guid.
refresh: i_crmtext.
endloop.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
endif.
ENDFUNCTION.
please Gurus as I donot know ABAP i appreciate if anyone would write a FM based on requirement and send me that will be really great this is my request. I gurantee of award points for good answers.
Regards
KishoreHi,
The statement <b>RAISE NO_MORE_DATA</b> should be active (uncommented) in your code. Otherwise, the infinte loop occurs.
See also, the Siggi's blog:
/people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
BTW, was it your thread here:
Re: Urgent: problems in extracting Long Text
Best regards,
Eugene
Maybe you are looking for
-
What are the units of "Width" and "Height" of a Shape?
What are the units of "Width" and "Height" properties of a Shape when programming? Something odd like points or twips or tweedles or nibbles? http://www.ransen.com Cad and Graphics software
-
I hooked up a LCD projector to the MacBook Pro and can see the Desktop, but when I try to run IPhoto it plays on laptop, but only the original image of the desktop is still projected. Is there a setting somewhere that would allow me to see IPhoto sli
-
Decided to put illustrator cs5 on Mac.
before this program was on windows enter the serial number, the program writes the code does not fit on the box written illustrator ret in what could be the problem?
-
Optimize Adobe PDF Size (Reduce) via Adobe LC Services.
I would like to know if there is a Service provided by Adobe LiveCycle ES2 which will reduce the size of a given PDF (Static or Dynamic) something similar to what you get using Acrobat menu option Optimize PDF. Tarek.
-
I have a nano 6th gen. Can I transfer content from my pc to the nano. I downloaded a language course from a cd to the pc.