04-01-2009 8:37 PM
i have created 2 custom tables::zhospital_info n zpatient_info..
zhospitalinfo tab fields:::_
doc_name::prim key
patient_name:::prim key
place::prim key
zpatientinfo tab fields::_
ZDATE ::prim key
JOINING
MEDICINE
PRICE
QUANTITY
DOC_NAME ::for key
PATIENT_NAME::for key
PLACE ::for key
and inserted some values to the table contents..
this is my logic:::
TYPES: BEGIN OF ZHOSPITAL_INFO,
DOC_NAME TYPE ZDOC_NAME,
PATIENT_NAME TYPE ZPATIENT_NAME,
PLACE TYPE ZPLACE,
END OF ZHOSPITAL_INFO.
DATA: W_HI TYPE ZHOSPITAL_INFO.
DATA:T_HI TYPE STANDARD TABLE OF ZHOSPITAL_INFO.
TYPES: BEGIN OF ZPATIENTL_INFO,
ZDATE TYPE ZDATE,
JOINING TYPE ZJOINING,
MEDICINE TYPE ZMEDICINE,
PRICE TYPE ZPRICE,
QUANTITY TYPE ZQUANTITY,
DOC_NAME TYPE ZDOC_NAME,
PATIENT_NAME TYPE ZPATIENT_NAME,
PLACE TYPE ZPLACE,
END OF ZPATIENTL_INFO.
DATA: W_PI TYPE ZPATIENTL_INFO.
DATA:T_PI TYPE STANDARD TABLE OF ZPATIENTL_INFO.
TYPES: BEGIN OF FTAB,
DOC_NAME TYPE ZDOC_NAME,
PATIENT_NAME TYPE ZPATIENT_NAME,
PLACE TYPE ZPLACE,
DATE TYPE ZDATE,
JOINING TYPE ZJOINING,
MEDICINE TYPE ZMEDICINE,
PRICE TYPE ZPRICE,
QUANTITY TYPE ZQUANTITY,
END OF FTAB.
DATA: W_FTAB TYPE FTAB,
T_FTAB TYPE STANDARD TABLE OF FTAB.
SELECT DOC_NAME
PATIENT_NAME
PLACE
INTO TABLE t_hi
FROM ZHOSPITAL_INFO .
IF NOT t_hi IS NOT INITIAL.
SELECT DOC_NAME
PATIENT_NAME
PLACE
ZDATE
MEDICINE*
PRICE
QUANTITY FROM ZPATIENTL_INFO INTO TABLE t_pi FOR ALL ENTRIES IN
t_hi
WHERE DOC_NAME = t_hi-doc_name.
ENDIF.
LOOP AT t_pi INTO w_pi.
MOVE-CORRESPONDING: w_pi TO W_FTAB.
READ TABLE t_hi INTO w_hi WITH KEY DOC_NAME = W_FTAB-DOC_NAME.
MOVE: w_hi-patient_name TO W_FTAB-PATIENT_NAME,
w_hi-place TO W_FTAB-PLACE.
APPEND W_FTAB TO T_FTAB.
ENDLOOP.
LOOP AT T_FTAB INTO W_FTAB.
WRITE:/ W_FTAB-DOC_NAME,
W_FTAB-PATIENT_NAME,
W_FTAB-PLACE,
W_FTAB-DATE,
W_FTAB-JOINING,
W_FTAB-MEDICINE,
W_FTAB-PRICE,
W_FTAB-QUANTITY.
ENDLOOP.
req output:::when i enter doc_name the related info accr to doc_name from the both tables should be display..
m getting no errors but i cant execute my prog..
please check out my code...
thanx in adv..
04-01-2009 8:41 PM
IF NOT t_hi IS NOT INITIAL.
Is that what you meant? Have you run this in debugging to see where the problem lies??
Rob
04-01-2009 8:58 PM
Hello Gundala
I assume the problem lies here:
" Duplicated negation !!!
IF NOT t_hi IS NOT INITIAL.
SELECT DOC_NAME
PATIENT_NAME
PLACE
ZDATE
* MEDICINE
PRICE
QUANTITY FROM ZPATIENTL_INFO INTO TABLE t_pi FOR ALL ENTRIES IN
t_hi
WHERE DOC_NAME = t_hi-doc_name.
ENDIF.
If T_HI is empty the IF statement is TRUE. However, T_HI-DOC_NAME is always empty so you will never select any patient data.
If T_HI is filled the IF statement is FALSE. The SELECT statement will be skipped which again means you will never select any patient data.
Instead of using negative IF conditions I prefer another construct:
IF ( t_hi IS INITIAL ).
" do nothing
ELSE.
" Select patient data
SELECT ...
ENDIF.
Regards
Uwe
04-01-2009 9:26 PM
Also, use the complety key here:
...
quantity
FROM zpatientl_info INTO TABLE t_pi
FOR ALL ENTRIES IN t_hi
WHERE doc_name = t_hi-doc_name
AND patient_name = t_hi-patient_name
AND place = t_hi-place.
04-02-2009 6:24 AM
hi,
In your logic u have putted IF NOT t_hi IS NOT INITIAL after the first selection qurey.
It means if t_hi is empty then only it will execute the following lines of code.
Please put only IF NOT t_hi IS INITIAL .
I hope i might help you.
Thanks,
Lokesh
04-02-2009 7:14 AM
Hi ,
put the break-point and check whether data is coming to all internal table or not.
and see your conditions are matching or not with what ur entering as i/p.
Regards
04-02-2009 3:12 PM
Hi!
instead of using IF NOT t_hi IS NOT INITIAL , use the cond if t_hi is not initial .
Also keep break point on first internal table and check wheteher data is comming into the table.
04-02-2009 6:30 PM
sorry it was a typing mistake
if t_hi is not initial..even though while debbuging m not getting values into the int tables
04-03-2009 9:20 AM
Hi,
The problem is in the select statement:
SELECT DOC_NAME
PATIENT_NAME
PLACE
ZDATE
MEDICINE
PRICE
QUANTITY FROM ZPATIENTL_INFO INTO TABLE t_pi FOR ALL ENTRIES IN
t_hi
WHERE DOC_NAME = t_hi-doc_name.
Change this to SELECT DOC_NAME PATIENT_NAME PLACE ZDATE MEDICINE PRICE QUANTITY FROM ZPATIENTL_INFO INTO CORRESPONDING FIELDS OF TABLE t-pi FOR ALL ENTRIES IN t_hi WHERE DOC_NAME = t_hi-doc_name.
I hope the above code will help you...
Also i hope to tell the following for performance issues and also a good programming practice:
LOOP AT t_pi INTO w_pi.
MOVE-CORRESPONDING: w_pi TO W_FTAB.
READ TABLE t_hi INTO w_hi WITH KEY DOC_NAME = W_FTAB-DOC_NAME.
MOVE: w_hi-patient_name TO W_FTAB-PATIENT_NAME,
w_hi-place TO W_FTAB-PLACE.
APPEND W_FTAB TO T_FTAB.
ENDLOOP.
Please do a sy-subrc check after READ statement always...
LOOP AT t_pi INTO w_pi.
MOVE-CORRESPONDING: w_pi TO W_FTAB.
READ TABLE t_hi INTO w_hi WITH KEY DOC_NAME = W_FTAB-DOC_NAME.
If sy-subrc = 0.
MOVE: w_hi-patient_name TO W_FTAB-PATIENT_NAME,
w_hi-place TO W_FTAB-PLACE.
clear w_hi.
Endif.APPEND W_FTAB TO T_FTAB.
ENDLOOP.
Please revert back for clarifications.
Best Regards,
Suresh
04-03-2009 10:27 AM
hi,
Tyy out with this
In your code in the looping part use this , This should work.....
LOOP AT t_pi INTO w_pi.
READ TABLE t_hi INTO w_hi WITH KEY DOC_NAME = w_pi-DOC_NAME.
w_ftab-DOC_NAME = W_PI-DOCNAME.
w_ftab-PATIENT = W_PI-PATIENT.
w_ftab-PALCE = W_PI-PLACE.
w_ftab-zdate = w_hi-zdate.
W_FTAB-JOINING = w_hi-joining.
W_FTAB-MEDICINE = w_hi-medicine.
W_FTAB-PRICE = w_hi-price.
W_FTAB-QUANTITY = w_hi-quantity.
APPEND W_FTAB TO T_FTAB.
CLEAR W_FTAB.
endloop