Friday, June 1, 2018

INTERVIEW QUESTION SAP ABAP

ABAP INTERVIEW QUESTION

ü  What is an ABAP data dictionary?
- ABAP 4 data dictionary describes the logical structures of the objects used in application development and shows how they are mapped to the underlying relational database in tables/views.

ü  What are domains and data element?
- Domains:Domain is the central object for describing the technical characteristics of an attribute of an business objects. It describes the value range of the field. Data Element: It is used to describe the semantic definition of the table fields like description the field. Data element describes how a field can be displayed to end-user.

ü  What is foreign key relationship?
- A relationship which can be defined between tables and must be explicitly defined at field level. Foreign keys are used to ensure the consistency of data. Data entered should be checked against existing data to ensure that there are now contradiction. While defining foreign key relationship cardinality has to be specified. Cardinality mentions how many dependent records or how referenced records are possible.

ü  Describe data classes.
- Master data: It is the data which is seldomly changed. Transaction data: It is the data which is often changed. Organization data: It is a customizing data which is entered in the system when the system is configured and is then rarely changed. System data:It is the data which R/3 system needs for itself.

ü  What are indexes?
- Indexes are described as a copy of a database table reduced to specific fields. This data exists in sorted form. This sorting form ease fast access to the field of the tables. In order that other fields are also read, a pointer to the associated record of the actual table are included in the index. Yhe indexes are activated along with the table and are created automatically with it in the database.

ü  Difference between transparent tables and pooled tables.
- Transparent tables: Transparent tables in the dictionary has a one-to-one relation with the table in database. Its structure corresponds to single database field. Table in the database has the same name as in the dictionary. Transparent table holds application data. Pooled tables. Pooled tables in the dictionary has a many-to-one relation with the table in database. Table in the database has the different name as in the dictionary. Pooled table are stored in table pool at the database level.

ü  What is an ABAP/4 Query?
- ABAP/4 Query is a powerful tool to generate simple reports without any coding. ABAP/4 Query can generate the following 3 simple reports: Basic List: It is the simple reports. Statistics: Reports with statistical functions like Average, Percentages. Ranked Lists: For analytical reports. - For creating a ABAP/4 Query, programmer has to create user group and a functional group. Functional group can be created using with or without logical database table. Finally, assign user group to functional group. Finally, create a query on the functional group generated.

ü  What is BDC programming?
- Transferring of large/external/legacy data into SAP system using Batch Input programming. Batch input is a automatic procedure referred to as BDC(Batch Data Communications).The central component of the transfer is a queue file which receives the data vie a batch input programs and groups associated data into “sessions”.

ü  What are the functional modules used in sequence in BDC?
- These are the 3 functional modules which are used in a sequence to perform a data transfer successfully using BDC programming: BDC_OPEN_GROUP - Parameters like Name of the client, sessions and user name are specified in this functional modules. BDC_INSERT - It is used to insert the data for one transaction into a session. BDC_CLOSE_GROUP - This is used to close the batch input session.

ü  What are internal tables?
- Internal tables are a standard data type object which exists only during the runtime of the program. They are used to perform table calculations on subsets of database tables and for re-organising the contents of database tables according to users need.

ü  What is ITS? What are the merits of ITS?
- ITS is a Internet Transaction Server. ITS forms an interface between HTTP server and R/3 system, which converts screen provided data by the R/3 system into HTML documents and vice-versa. Merits of ITS: A complete web transaction can be developed and tested in R/3 system. All transaction components, including those used by the ITS outside the R/3 system at runtime, can be stored in the R/3 system. The advantage of automatic language processing in the R/3 system can be utilized to language-dependent HTML documents at runtime.

ü  What is DynPro?
- DynPro is a Dynamic Programming which is a combination of screen and the associated flow logic Screen is also called as DynPro.

ü  What are screen painter and menu painter?
- Screen painter: Screen painter is a tool to design and maintain screen and its elements. It allows user to create GUI screens for the transactions. Attributes, layout, filed attributes and flow logic are the elements of Screen painter. Menu painter: Menu painter is a tool to design the interface components. Status, menu bars, menu lists, F-key settings, functions and titles are the components of Menu painters. Screen painter and menu painter both are the graphical interface of an ABAP/4 applications.

ü  What are the components of SAP scripts?
- SAP scripts is a word processing tool of SAP which has the following components: Standard text. It is like a standard normal documents. Layout sets. - Layout set consists of the following components: Windows and pages, Paragraph formats, Character formats. Creating forms in the R/3 system. Every layout set consists of Header, paragraph, and character string. ABAP/4 program.

ü  What is ALV programming in ABAP? When is this grid used in ABAP?
- ALV is Application List viewer. Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain up to 90 columns in the display with the wide array of display options.

ü  What are the events in ABAP/4 language?
- Initialization, At selection-screen, Start-of-selection, end-of-selection, top-of-page, end-of-page, At line-selection, At user-command, At PF, Get, At New, At LAST, AT END, AT FIRST.

ü  What is CTS and what do you know about it?
- The Change and Transport System (CTS) is a tool that helps you to organize development projects in the ABAP Workbench and in Customizing, and then transport the changes between the SAP Systems and clients in your system landscape. This documentation provides you with an overview of how to manage changes with the CTS and essential information on setting up your system and client landscape and deciding on a transport strategy. Read and follow this documentation when planning your development project.

ü  What are logical databases? What are the advantages/ dis-advantages of logical databases?
- To read data from a database tables we use logical database. A logical database provides read-only access to a group of related tables to an ABAP/4 program. Advantages: i)check functions which check that user input is complete, correct,and plausible. ii)Meaningful data selection. iii)central authorization checks for database accesses. iv)good read access performance while retaining the hierarchical data view determined by the application logic. dis advantages: i)If you donot specify a logical database in the program attributes,the GET events never occur. ii)There is no ENDGET command,so the code block associated with an event ends with the next event statement (such as another GET or an END-OF-SELECTION).

ü  What is a batch input session?
- BATCH INPUT SESSION is an intermediate step between internal table and database table. Data along with the action is stored in session ie data for screen fields, to which screen it is passed, program name behind it, and how next screen is processed.

ü  How to upload data using CATT ?
- These are the steps to be followed to Upload data through CATT: Creation of the CATT test case & recording the sample data input. Download of the source file template. Modification of the source file. Upload of the data from the source file.

ü  What is Smart Forms?
- Smart Forms allows you to create forms using a graphical design tool with robust functionality, color, and more. Additionally, all new forms developed at SAP will be created with the new Smart Form solution.

ü  How can I make a differentiation between dependent and independent data?
- Client dependent or independent transfer requirements include client specific or cross client objects in the change requests. Workbench objects like SAPscripts are client specific, some entries in customizing are client independent. If you display the object list for one change request, and then for each object the object attributes, you will find the flag client specific. If one object in the task list has this flag on, then that transport will be client dependent.

ü  What is the difference between macro and subroutine?
- Macros can only be used in the program the are defined in and only after the definition are expanded at compilation / generation. Subroutines (FORM) can be called from both the program the are defined in and other programs . A MACRO is more or less an abbreviation for some lines of code that are used more than once or twice. A FORM is a local subroutine (which can be called external). A FUNCTION is (more or less) a subroutine that is called external. Since debugging a MACRO is not really possible, prevent the use of them (I’ve never used them, but seen them in action). If the subroutine is used only local (called internal) use a FORM. If the subroutine is called external (used by more than one program) use a FUNCTION.


ü  How data is stored in cluster table? 
Each field of cluster table behaves as tables which contains the no. of entries. 

ü  What are client dependant objects in abap/sap? 
SAP Script layout, text element, and some DDIC objects. 

ü  On which even we can validate the input fields in module progams? 
In PAI (Write field statement on field you want to validate, if you want to validate group of fields put in chain and End chain statement.) 

ü  In selection screen I have three fields, plant mat no and material group. If I input plant how do I get the mat no and material group based on plant dynamically? 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR MATERIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' to get material and material group for the plant. 

ü  How do you get output from IDOC? 
Data in IDOc is stored in segments, the output from Idoc is obtained by reading the data stored in its respective segments. 

ü  When top of the page event is triggered? 
After excuteing first write statement in start-of-selection event. 

ü  Can we create field without data element and how? 
In SE11 one option is available above the fields strip. Data element/ direct type. 

ü  How do we debug sapscript? 
Go to SE71 give lay set name , go to utilities select debugger mode on.

ü  Which transaction code can I used to analyze the performance of ABAP program. 
TCode AL21.

ü  How can I copy a standard table to make my own z_table.
Go to transaction SE11. Then there is one option to copy table. Press that button.  Enter the name of the standard table and in the Target table enter Z table name and press enter.

ü  Following are some of the answers which I gave upto my knowledge.

ü  1. What is the use of 'outerjoin' 
Ans. With the use of outer join you can join the tables even there is no entry in all the tables used in the view.
        In case of inner join there should be an entry in al the tables use in the view.

ü  2. When to  use logical database?
Ans. Advantage of Logical databases:
        less coding s required to retrieve data compared to normal internel tables.
        Tables used LDB are in hierarchial structure.

ü  3. What is the use of 'table index'?
Ans .Index is used for faster access of data base tables.

ü  4. What is the use of 'FOR ALL ENTRIES'?
Ans. To avoid nested select statements we use SELECT FOR ALL ENTRIES statement.
        If there r more than 10000 records SELECT FOR ALL ENTRIES is used.
        Performance wise SELECT FOR ALL ENTRIES is better to use.

ü  5. Can you set up background processing using CALL TRANSACTION?
       Yes,Using No Screen Mode.

ü  6. What are table buffers?
    Table buffers reside locally on each application server in the system. The data of buffered tables can thus be accessed
    directly  from the buffer of the application server. This avoids the time-consuming process of accessing the database.

ü  Buffering is useful if table needs to be accessed more no. of times in a program.

ü  

ü  How do I set a flag for a field in any table?
Create a char field of length 1. for example field STAS-LKENZ is Deletion Indicator. It means that if the value in the field is 'X' then that record has been deleted.

ü  Can I execute user exits? If yes, how?
Yes you can. after finding the user exit, you need to use, goto CMOD add ur user-exit to your project. Then activate the FM which you require. Now go into that function module there will be a Include program wit name ZX* . Double click on it, it will ask to create an object, answer it Yes and then write your code in it. 

ü  How do I find the output type of a table or a program?
Table TNAPR / NAST





Wednesday, May 30, 2018

SAP ABAP:--BTE (Business Transaction and Event).


BTE (Business Transaction and Event).


Title : Perform Validation on t-code FB60 Using BTE Business Transaction and Event enhancement    process.
Using  InfoSystem  Processes:
 Step-1:  Go to t-code FB60 à System àStatus à Double Click on Program (screen) SAPMF05A 



Step-2: After Continue goto System Menu Status à double click on Program (Screen) àthen click on Find à Find = OPEN_FI_PERFORM àSelect Radio button in main Program à Continue.


Step-3: Select Appropriate Enhancement point/program regarding your requirement (Ex.Here we select MF05AFO0_OPEN_FI_SUBSTITUTION Enhancement point/program).


Step-4 : Put break-point  at the function to Check Our requirement à Double click on CALL FUNCTION ‘OPEN_FI_PERFORM_00001120_P àContinue àput break point à  select SAPMF02D àBack àBack.


Step-5: go to t-code FB60 and Enter Company code , Vendor , Invoice date , Posting Date , Amount ,GL account and Amount in Doc.curr , BaselineDt  à save


Step-6: Go to  T-code FIBF  à Environment àInfo System(P/S) à Enter Business Transaction Event =  00001120 (BTE for CALL FUNCTION OPEN_FI_PERFORM_00001120_P)  


è Next click on Sample code.
Step-7: First Of all Create a Function Group (ex. ZSN_BTE_FG) in t-code SE80  àActivate.
Step-8: Next click on Sample code à Copy Standard SAMPLE_INTERFACE_00001120 Function Module into  custom function Module (Ex. ZSN_BTE_FB60_FM).

Step-9: Change the custom Function Module ZSN_BTE_FB60_FM à Put Your Condition In This Function Module à Save à Activate
Step-10: Go to T-code FIBF à Setting à Product à Of a Customer àNew Enterries àProvide Product Name = ZSN_FB60 à text = Validation for FD60 à Save à Back .

Step-11: Go to Setting à Processes Module à Of a Customer àNew Enterries àProvide Event  = 00001120 à Product = ZSN_FB60 à Function Module = ZSN_BTE_FB60_FM à Save à Back
Note :  In Processes Module we can define /create Processes with Event (ex.00001120) single time only.(Single Implementation)

 Step-12: Go to  Setting à Product à Of a Customer à Provide Product Name = ZSN_FB60  à Active à Save à Back .

Step-13: Go to t-code FB60 àEnter Fields value.


 output



















Friday, May 11, 2018

SAP ABAP- Enhancements Function Exit or Customer Exit.

Q.Enhancements Function Exit or Customer Exit.

Function Exit (this is customer exit). Here we discuss about the Function Exit or Customer Exit. This is the details about step of example. We already predefine predefined a particular value of sales order. Step by step sales order creation in (VA01 transaction). This sales order creation there is a field ‘SOLD TO PARTY’. We want this field will be predefined with value 2400 whenever we enter VA01. Following is the step by step approach.
A. Please enter VA01 transaction.



B.After that please enter order type OR and press enter.




 C. Initially the sold to party is blank. Sold to party means the party to whom the product will be sold. So basically it will be the customer.



 D. Now go to system > status and double click on the program.

 E. If you want to copy the package > go to attribute > copy the package name.

 F. Next > SMOD and then find (CTRL + F).


 G. After you put package (VA) and execute.

 H. Now we see that there are a lot of exits for this particular transaction VA01. We have to go by the description of exits and we have chosen Predefined sold-to-party.

 H. Double click on the exit and we enter into the enhancement.

J. Now double click on the exit and we enter into the function module (SE37).

 K. Now go to CMOD and create a project.


 L. Enter the enhancement name and hit enter.

 M. Now double click on the exit.

 N. Create the include program to write our own code.

O. Activate the code and activate the project. We see that the exporting parameter takes the value of customer number with E_KUNNR like KNA1-KUNNR. So we are passing a fixed value to E_KUNNR.


 P. Now again enter VA01 with OR order type.



 Q. We can deactivate this project and by doing this VA01 will go to previous phase.


Wednesday, May 9, 2018

SAP ABAP-JOIN TWO TABLE IN SAP ABAP REPORT .USE FOR ALL ENTRIES IN IN SAP ABAP.

USE FOR ALL ENTRIES IN IN SAP ABAP

REPORT  ZJOINQUERY.
TYPES: BEGIN OF ty_LIKP,
     VBELN TYPE VBELN_VL,
     ERZET TYPE ERZET,
     ERNAM TYPE ERNAM,
    END OF ty_LIKP,

BEGIN OF ty_LIPS,
    VBELN TYPE VBELN_VL,
    POSNR TYPE POSNR_VL,
    PSTYV TYPE PSTYV_VL,
  END OF ty_LIPS,

 BEGIN OF ty_final,
     VBELN TYPE VBELN_VL,

     ERZET TYPE ERZET,
     ERNAM TYPE ERNAM,

     POSNR TYPE POSNR_VL,
     PSTYV TYPE PSTYV_VL,

     END OF ty_final.


 DATA: it_LIKP TYPE STANDARD TABLE OF ty_LIKP,
      wa_LIKP TYPE ty_LIKP,
      it_LIPS TYPE STANDARD TABLE OF ty_LIPS,
      wa_LIPS TYPE ty_LIPS,
      it_final TYPE STANDARD TABLE OF ty_final,
      wa_final TYPE ty_final,
      gv_vbeln TYPE vbeln_vL.

SELECTION-SCREEN BEGIN OF BLOCK s WITH FRAME TITLE text-009.
SELECT-OPTIONS: s_vbeln FOR gv_vbeln.
SELECTION-SCREEN END OF BLOCK s.


START-OF-SELECTION.
  SELECT   VBELN
           ERZET
           ERNAM
         FROM LIKP INTO TABLE it_LIKP
         WHERE vbeln IN s_vbeln.
  IF sy-subrc = 0.
    SORT it_LIKP BY vbeln.
  ENDIF.
  IF it_LIKP IS NOT INITIAL.


  SELECT  VBELN
          POSNR
          PSTYV
          FROM LIPS INTO TABLE it_LIPS
          FOR ALL ENTRIES IN it_LIKP
          WHERE vbeln = it_LIKP-vbeln.
    IF sy-subrc = 0.
      SORT it_LIPS BY vbeln.
    ENDIF.
  ENDIF.


   LOOP AT it_LIPS INTO wa_LIPS.

    wa_final-vbeln = wa_LIPS-vbeln.
    wa_final-POSNR = wa_LIPS-POSNR.
    wa_final-PSTYV  = wa_LIPS-PSTYV .

    READ TABLE it_LIKP INTO wa_LIKP
    WITH KEY vbeln = wa_LIKP-VBELN.
    IF sy-subrc = 0.

    wa_final-ERZET = wa_LIKP-ERZET.
    wa_final-ERNAM = wa_LIKP-ERNAM.


    ENDIF.
    APPEND wa_final TO it_final.
    CLEAR : wa_final , wa_LIPS , wa_LIKP.
  endloop.

  LOOP AT it_final into wa_final.
  WRITE:/ wa_final-vbeln,
          wa_final-ERZET,
          wa_final-ERNAM,
          wa_final-posnr,
          wa_final-PSTYV.
          .





  ENDLOOP.

SAP ABAP - SIMPLE CLASSICAL REPORT


CLASSICAL REPORT  IN SAP ABAP

*&---------------------------------------------------------------------*
*& Report  ZSIBLING_AGE_DIFF
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZSIBLING_AGE_DIFF.

TYPES: BEGIN OF TY_FATHER,
        FATHERID TYPE ZFATHERID,
        FATHERNAME TYPE ZFATHERNAME,
        FATHERDOB TYPE ZFATHERDOB,
       END OF TY_FATHER.
TYPES: BEGIN OF TY_MOTHER,
        MOTHERID TYPE ZMOTHERID,
        HUSBANDID TYPE ZFATHERID,
        MOTHERNAME TYPE ZMOTHERNAME,
        MOTHERDOB TYPE ZMOTHERDOB,
       END OF TY_MOTHER.
TYPES: BEGIN OF TY_CHILDREN,
        CHILDID TYPE ZCHILDID,
        FATHERID TYPE ZFATHERID,
        MOTHERID TYPE ZMOTHERID,
        CHILDNAME TYPE ZCHILDNAME,
        CHILDDOB TYPE ZCHILDDOB,
        CHILDGENDER TYPE ZCHILDGENDER,
       END OF TY_CHILDREN.




TYPES: BEGIN OF TY_CHILD_AGE,
       FATHERNAME TYPE ZFATHERNAME,
       CHILDNAME TYPE ZCHILDNAME,
       CHILDID TYPE ZCHILDID,
       YEARS TYPE NUM2,
       END OF TY_CHILD_AGE.

TYPES: BEGIN OF TY_FINAL,
        CHILDID TYPE ZCHILDID,
        FATHERNAME TYPE ZFATHERNAME,
        CHILDNAME TYPE ZCHILDNAME,
        CHILDAGE TYPE I,
        FIRSTDIFF TYPE I,
        SECONDDIFF TYPE I,
        THIRDDIFF TYPE I,
       END OF TY_FINAL.
DATA: IT_FINAL TYPE TABLE OF TY_FINAL,
      WA_FINAL TYPE TY_FINAL.

DATA: IT_CHILD_AGE1 TYPE TABLE OF TY_CHILD_AGE,
      WA_CHILD_AGE1 TYPE TY_CHILD_AGE,
      LINE_COUNT TYPE I,
      AGE TYPE I,
      AGE1 TYPE I,
      AGE_DIFF TYPE I.
DATA: IT_CHILD_AGE TYPE TABLE OF TY_CHILD_AGE,
      WA_CHILD_AGE TYPE TY_CHILD_AGE.

DATA: IT_FATHER TYPE TABLE OF TY_FATHER,
      WA_FATHER TYPE TY_FATHER.
DATA: IT_MOTHER TYPE TABLE OF TY_MOTHER,
      WA_MOTHER TYPE TY_MOTHER.
DATA: IT_CHILDREN TYPE TABLE OF TY_CHILDREN,
      WA_CHILDREN TYPE TY_CHILDREN.

"DATA: S_FATHERID TYPE ZFATHER-FATHERID.
DATA: DAYS TYPE NUM2,
      MONTHS TYPE NUM2,
      YEARS TYPE NUM2.
DATA: V_LINES TYPE I.

SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
  PARAMETERS: P_FID TYPE ZFATHER-FATHERID.
SELECTION-SCREEN: END OF BLOCK B1.

START-OF-SELECTION.
SELECT CHILDID FATHERID MOTHERID CHILDNAME CHILDDOB CHILDGENDER FROM ZCHILDREAN INTO TABLE IT_CHILDREN
  WHERE FATHERID EQ P_FID.
  IF SY-SUBRC EQ 0.
    SORT IT_CHILDREN BY CHILDID.

    SELECT FATHERID FATHERNAME FATHERDOB FROM ZFATHER INTO TABLE IT_FATHER FOR ALL ENTRIES IN IT_CHILDREN
      WHERE FATHERID = IT_CHILDREN-FATHERID.
  ENDIF.
END-OF-SELECTION.

LOOP AT IT_CHILDREN INTO WA_CHILDREN.

  READ TABLE IT_FATHER INTO WA_FATHER WITH KEY FATHERID = WA_CHILDREN-FATHERID BINARY SEARCH.
  WA_CHILD_AGE-FATHERNAME = WA_FATHER-FATHERNAME.

  WA_CHILD_AGE-CHILDNAME = WA_CHILDREN-CHILDNAME.
  WA_CHILD_AGE-CHILDID = WA_CHILDREN-CHILDID.

  CALL FUNCTION 'HRCM_TIME_PERIOD_CALCULATE'
  EXPORTING
  BEGDA = WA_CHILDREN-CHILDDOB
  ENDDA = SY-DATUM
  IMPORTING
  NOYRS = YEARS
  NOMNS = MONTHS
  NODYS = DAYS
  EXCEPTIONS
  INVALID_DATES = 1
  OVERFLOW = 2
  OTHERS = 3.
  WA_CHILD_AGE-YEARS = YEARS.


  APPEND WA_CHILD_AGE TO IT_CHILD_AGE.
  CLEAR WA_CHILD_AGE.
ENDLOOP.



IT_CHILD_AGE1[] = IT_CHILD_AGE.

DESCRIBE TABLE IT_CHILD_AGE LINES V_LINES.
WRITE:/ 'TOTAL CHILD:-',V_LINES.
ULINE.

WRITE:/ 'FATHER NAME',
        20 'CHILD NAME',
        40 'CHILD AGE',
        60 'FIRST DIFF',
        80 'SECOND DIFF',
        100 'THIRD DIFF'.
ULINE.

LOOP AT IT_CHILD_AGE INTO WA_CHILD_AGE.
  WA_FINAL-CHILDID = WA_CHILD_AGE-CHILDID.
  WA_FINAL-FATHERNAME = WA_CHILD_AGE-FATHERNAME.
  WA_FINAL-CHILDNAME = WA_CHILD_AGE-CHILDNAME.
  WA_FINAL-CHILDAGE = WA_CHILD_AGE-YEARS.
*  WA_FINAL-FIRSTDIFF = ''.
*  WA_FINAL-SECONDDIFF = ''.
*  WA_FINAL-THIRDDIFF = ''.

  APPEND WA_FINAL TO IT_FINAL.
  CLEAR WA_FINAL.
ENDLOOP.



LOOP AT IT_CHILD_AGE INTO WA_CHILD_AGE.
*  WRITE:/ WA_CHILD_AGE-FATHERNAME,
*          20 WA_CHILD_AGE-CHILDNAME,
*          40 WA_CHILD_AGE-YEARS.

          WA_FINAL-FATHERNAME = WA_CHILD_AGE-FATHERNAME.
          WA_FINAL-CHILDNAME = WA_CHILD_AGE-CHILDNAME.
          WA_FINAL-CHILDAGE = WA_CHILD_AGE-YEARS.

          LINE_COUNT = 1.
          LOOP AT IT_CHILD_AGE1 INTO WA_CHILD_AGE1.
            IF WA_CHILD_AGE-CHILDID NE WA_CHILD_AGE1-CHILDID.
              IF WA_CHILD_AGE-YEARS GT WA_CHILD_AGE1-YEARS.
                AGE = WA_CHILD_AGE-YEARS.
                AGE1 = WA_CHILD_AGE1-YEARS.
                AGE_DIFF = AGE - AGE1.
                IF LINE_COUNT EQ 1.
                  WA_FINAL-FIRSTDIFF = AGE_DIFF.
                  MODIFY IT_FINAL FROM WA_FINAL TRANSPORTING FIRSTDIFF WHERE CHILDID = WA_CHILD_AGE-CHILDID.
                ENDIF.
                IF LINE_COUNT EQ 2.
                  WA_FINAL-SECONDDIFF = AGE_DIFF.
                  MODIFY IT_FINAL FROM WA_FINAL TRANSPORTING SECONDDIFF WHERE CHILDID = WA_CHILD_AGE-CHILDID.
                ENDIF.
                IF LINE_COUNT EQ 3.
                  WA_FINAL-THIRDDIFF = AGE_DIFF.
                  MODIFY IT_FINAL FROM WA_FINAL TRANSPORTING THIRDDIFF WHERE CHILDID = WA_CHILD_AGE-CHILDID.
                ENDIF.
                "WRITE:/ AGE_DIFF.
              ELSE.
                AGE = WA_CHILD_AGE1-YEARS.
                AGE1 = WA_CHILD_AGE-YEARS.
                AGE_DIFF = AGE - AGE1.
                IF LINE_COUNT EQ 1.
                  WA_FINAL-FIRSTDIFF = AGE_DIFF.
                  MODIFY IT_FINAL FROM WA_FINAL TRANSPORTING FIRSTDIFF WHERE CHILDID = WA_CHILD_AGE-CHILDID.
                ENDIF.
                IF LINE_COUNT EQ 2.
                  WA_FINAL-SECONDDIFF = AGE_DIFF.
                  MODIFY IT_FINAL FROM WA_FINAL TRANSPORTING SECONDDIFF WHERE CHILDID = WA_CHILD_AGE-CHILDID.
                ENDIF.
                IF LINE_COUNT EQ 3.
                  WA_FINAL-THIRDDIFF = AGE_DIFF.
                  MODIFY IT_FINAL FROM WA_FINAL TRANSPORTING THIRDDIFF WHERE CHILDID = WA_CHILD_AGE-CHILDID.
                ENDIF.
                "WRITE:/ AGE_DIFF.
              ENDIF.
              LINE_COUNT = LINE_COUNT + 1.
            ENDIF.

*            APPEND WA_FINAL TO IT_FINAL.
*            CLEAR WA_FINAL.

          ENDLOOP.
ENDLOOP.

LOOP AT IT_FINAL INTO WA_FINAL.
  WRITE:/ WA_FINAL-FATHERNAME,
          20 WA_FINAL-CHILDNAME,
          40 WA_FINAL-CHILDAGE,
          60 WA_FINAL-FIRSTDIFF,
          80 WA_FINAL-SECONDDIFF,
          100 WA_FINAL-THIRDDIFF.
ENDLOOP.

*
*TYPES: BEGIN OF TY_CHILD_AGE,
*       FATHERNAME TYPE ZFATHERNAME,
*       CHILDNAME TYPE ZCHILDNAME,
*       CHILDID TYPE ZCHILDID,
*       YEARS TYPE NUM2,
*       END OF TY_CHILD_AGE.
*DATA: IT_CHILD_AGE TYPE TABLE OF TY_CHILD_AGE,
*      WA_CHILD_AGE TYPE TY_CHILD_AGE.