Application Development and Automation 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: 
Read only

HELP REQUIRED EXPERIENCED ABAP DEVELOPER.

Former Member
0 Likes
567

Hello experts.

i am learning ABAP. i found in very interesting yet a bit confusing  programming language.

i am in need of some help from an expert for my problems.

I have a flow diagram for which i have tried coding. but in some situations i am unable to find a fit solution for the problem.

the code is below and diagram is attached in a file.

I HAVE DIVIDED THE DIAGRAM IN STEPS AND CODED ACCORDINGLY.

CODE :

TABLES: ZPATCORE, ZNPAT, ZNBEW.

DATA:  wa_ZPATSE TYPE ZPATSE,

            wa_ZPATCORE TYPE ZPATCORE,

             wa_ZNBEW TYPE ZNBEW,

             wa_ZNPAT TYPE ZNPAT

       date_today TYPE  d,

       alldays TYPE i.

DATA:       ITAB1 LIKE ZPATCORE,          /////// comment ////////// creating internal tables for Database tables.

            ITAB2 LIKE ZNPAT,

            ITAB3 LIKE ZNBEW.


SELECT * FROM ZAPTCORE INTO ITAB1.

SELECT * FROM ZNPAT INTO ITAB2.

SELECT * FROM ZNBEW INTO ITAB3.


1) Read all combination of PatID and FallID and BettNr from ZNBEW where:

Fach=’its’ and behend=”31.12.9999”

select PatID,FallID,BettNr

from ZNBEW

into wa_ZNBEW

where fach EQ ‘its’

and behend EQ “31.12.9999”

and  NOT BettNr  eq ‘99’.                           //////////// comment ////////////// the value with znbew-BettNr NOT EQ ‘99’ is not passed further.

2)      If combination of PatID and FallID exists in ZPATCORE and ZNBEW-BettNr not= “99”

IF sy-subrc EQ 0 wa_ZPATCORE IS INITIAL.

Select PatID ,FallID

From ZPATCORE

Into wa_ZPATCORE

Where  PatID EQ wa_ZNBEW-PatID

And FallID EQ wa_ZNBEW-FallID.


3)      Read name and vorname  and gebudat from ZNPAT where id=PatID

4)      Read ifdnr and itstag from ZPATCORE.


IF sy-subrc EQ 0.

SELECT * FROM ZNPAT INTO TABLE ITAB2

FOR ALL ENTRIES IN ITAB1

WHERE PatID = ITAB1-PatID.


          * Alldays=date _today-itstag

         date_ today = sy_datum .

alldays=  date_today –  wa_ZPATCORE-itstag    //////// as i know that days= date_1- date_2 or i should use  a function module called "C14B_DIFF_BT_2_DATES "

 

     For String output

SELECT  PatID, Ifdnr,  BettNr  FROM ZNBEW INTO TABLE ITAB3

FOR ALL ENTRIES IN ITAB2

WHERE PatID = ITAB2-PatID.   ////////////////////////// for the value of BettNr from table znbew according to PatID of table  ZNPAT

LOOP AT ITAB3.

     Write: / ‘ifd:’ ITAB3-Ifdnr,

                ‘Bett:’ ITAB3-BettNr ,

                ‘Name,Vorname:’ ITAB3-Name ITAB3-Vorname,

                ITAB3-Gebdat,

                ‘Tag:’ITAB3-alldays.

END LOOP.

xxx---------------------------------------------------------------------------------------xxx

DATABASE TABLES USED FOR THE DIAGRAM AND DESCRIPTION.

Tables:

ZNBEW:
-lfdnr (integer)
-PatID (integer)
-FallID (integer)
-BettNr (integer)
-fach (string)
-behend (date)

=>Comment: There are lines with the same PatID and FallID, lfdnr is a number from 1 to n.
at every combination of PatID and FallID, lfdnr is only once there
Example:
PatID       FallID      lfdnr
4                1               1
4                1                2
4                1                 3
4                  3                1
ZPATCORE:
-PatID
-FallID
-BewID
-aufnahmestatus_vollst (char)
-entlassstatus_vollst (char)
-itstag(date)

-ifdnr

=>Comment: There Every line with  PatID and FallID has a different value of BewID


ZNPAT:
-PatID
-Name(string)
-Vorname(string)
-Gebudat(date)

**alldays=date_today-itstag

alldays is the number of days beetween date_today and itstag.
itstag is allways a date earlier than date_today.

MY QUESTIONS ARE :

1) How to loop for the next combination? (from  flow diagram)

2) Is it ok to use “wa_ZPATCORE-itstag” for the calculation of ‘alldays’ calculation?

(* Alldays=date _today-itstag)

3) I have used ‘FOR ALL ENTRIES’ instead of joins? So is it ok to use them or joins are more beneficial?

4) will the code work as the diagram intended it to work?

***** please note flow diagram is in a file 'img.png' attached to this post.

thank you.


1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
523

Hi Ojaswa,

It's good that u r trying things out. Based on the diagram flow, I'll try to help u with the concept.

Getting the code ready made for u is a bit of an exercise here.

->  loop / endlloop will take u to next combinations

->  dont use joins in any real time scenarios. Instead, Use for all entries and dont hesitate to do more processing in internal tables Using Read , Binary search

declare internal tables of standard types.

select * from znbew into table t_znbew

where fach = 'its' and behend = '31.12.9999'.

if sy-subrc eq 0.

select statement for zpatcore into table t_zpatcore for all entries in t_znbew

select statement for znpat into table t_znpat for all entries in t_zpatcore

endif.

sort the internal tables based on key fields.

Loop at t_znbew into wa_znbew.

read table t_zpatcore into wa_zpatcore

if sy-subrc eq 0 and wa_znbew-bettnr ne '-99'.

read table t_znpat into wa_znpat with key id = wa_znbew-patid.

if sy-subrc eq 0.

* operations and conditions

endif

endif

endloop.                              " Loop at t_znbew into wa_znbew.

Thanks

Vivek

2 REPLIES 2
Read only

Former Member
0 Likes
524

Hi Ojaswa,

It's good that u r trying things out. Based on the diagram flow, I'll try to help u with the concept.

Getting the code ready made for u is a bit of an exercise here.

->  loop / endlloop will take u to next combinations

->  dont use joins in any real time scenarios. Instead, Use for all entries and dont hesitate to do more processing in internal tables Using Read , Binary search

declare internal tables of standard types.

select * from znbew into table t_znbew

where fach = 'its' and behend = '31.12.9999'.

if sy-subrc eq 0.

select statement for zpatcore into table t_zpatcore for all entries in t_znbew

select statement for znpat into table t_znpat for all entries in t_zpatcore

endif.

sort the internal tables based on key fields.

Loop at t_znbew into wa_znbew.

read table t_zpatcore into wa_zpatcore

if sy-subrc eq 0 and wa_znbew-bettnr ne '-99'.

read table t_znpat into wa_znpat with key id = wa_znbew-patid.

if sy-subrc eq 0.

* operations and conditions

endif

endif

endloop.                              " Loop at t_znbew into wa_znbew.

Thanks

Vivek

Read only

paul_bakker2
Active Contributor
0 Likes
523

Hi,

If your Z tables are large (or will become so in future), you would be much better off using JOINs.

cheers

Paul