Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

for all entries on custom tables

Former Member
0 Kudos

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..

9 REPLIES 9

Former Member
0 Kudos
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

uwe_schieferstein
Active Contributor
0 Kudos

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

former_member182114
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

sorry it was a typing mistake

if t_hi is not initial..even though while debbuging m not getting values into the int tables

0 Kudos

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

Former Member
0 Kudos

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