on 02-11-2010 4:59 AM
hi guys,
I am fetching data from db table "mcha". now in the follwing code i get it in "HSDAT1_DATE."
now when i read out_tab with key "HSDAT1". it wont come in out_tab-value.plz tell me what is wrong whether some key condition in out_tab or any thing else.
and what should i write in changing && in script.
thanks in advance
FORM DATE_MGF TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
tables :MCHA ,QALS.
DATA : WERKS1 LIKE QALS-WERK.
DATA : HSDAT1 LIKE MCHA-HSDAT.
DATA : DATE(2),
MONTH(2),
YEAR(4).
DATA : HSDAT1_DATE(10).
READ TABLE IN_TAB WITH KEY 'QALS-WERK'.
LOOP AT IN_TAB.
IF SY-TABIX EQ 1.
WERKS1 = IN_TAB-VALUE.
IF WERKS1 NE SPACE.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
SELECT SINGLE HSDAT INTO HSDAT1
FROM MCHA
WHERE WERKS = WERKS1.
DATE = HSDAT1+6(2).
MONTH = HSDAT1+4(2).
YEAR = HSDAT1+0(4).
CONCATENATE DATE '.' MONTH '.' YEAR INTO HSDAT1_DATE.
READ TABLE OUT_TAB WITH KEY 'HSDAT1' .
IF SY-SUBRC = 0.
OUT_TAB-VALUE = HSDAT1.
MODIFY OUT_TAB INDEX SY-TABIX.
ENDIF.
Hi,
Did you check your table OUT_TAB, what is the format of date in this table. Please tell me 2-3 values of your internal table. So that we can check whether your read is sucessful.
Thanks,
Archana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
i hv pass out_tab-value = HSDAT1_date.
in above code it was by mistake.
now archana i havent get you.initally mine out_tab is blank..this is the only code i hv writen...
but mine HSDAT1_DATE =00.00.0000. it is stored in this manner only in db table mcha.and i m fetching it on the basis of qals-werk.
Hi,
Let me understanf clearly what you want.
initally mine out_tab is blank
According to you, your table out_tab is blank. And you need to add out_tab-value = HSDAT1_date.
READ TABLE OUT_TAB WITH KEY 'HSDAT1' .
IF SY-SUBRC = 0.
OUT_TAB-VALUE = HSDAT1.
MODIFY OUT_TAB INDEX SY-TABIX.
ENDIF.
So, if your table is blank, then read statement will fail.
Please let me know if your table out_tab in blank when you are reading the table and if this table contains any field called HSDAT.
Basically i would like to know your internal table out_tab declaration.
Thanks,
Archana
Hi,
If you want to add date field to your internal table out_tab.
Then you refer to below code.
SELECT SINGLE HSDAT INTO HSDAT1
FROM MCHA
WHERE WERKS = WERKS1.
DATE = HSDAT1+6(2).
MONTH = HSDAT1+4(2).
YEAR = HSDAT1+0(4).
CONCATENATE DATE '.' MONTH '.' YEAR INTO HSDAT1_DATE.
Append HSDAT1_DATE to out_tab.
Thanks,
Archana
hi archana,
now out_tab has 2 fields name and value.in name after appending the value are coming.but its not updating the read statemnt.
thrfor the out_tab-value remains blank.
the loop comes out from sy-subrc.
APPEND HSDAT1_DATE TO OUT_TAB.
READ TABLE OUT_TAB WITH KEY VALUE = 'HSDAT1' .
IF SY-SUBRC = 0.
OUT_TAB-VALUE = HSDAT1_DATE.
MODIFY OUT_TAB INDEX SY-TABIX.
ENDIF.
HEY archana,
actually i am passing HSDAT1_DATE to changing parameter.but in output it shows blank.plz chk i hv written
below code in sapscript.
/:PERFORM DATE_MGF IN PROGRAM ZORDER_DATE1
/:USING &QALS-WERK&
/:CHANGING &HSDAT1_DATE&
/:ENDPERFORM
date : &HSDAT1_DATE&
but in date i m getting blank value i hv chekd in debug.
some prob with output printing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kt,
Your read statement should be like this:
READ TABLE OUT_TAB WITH KEY VALUE = HSDAT1 .
Change the first read statement also accordingly.
Regards,
Swarna Munukoti.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.