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

How to Move Data from one Database table(All fields TYPEC) to another database table (All fields TYPE C and 1 only Type DEC)

Former Member
0 Likes
2,429

Dear Experts,

I am performing the folowing task:

1) To upload an .AZT file.

2) To SPLIT the data of this uploaded .AZT file at every ";"

3) Save this Splitted data to a data base table.

4) Now I want to perform Sum on one of the Data column of this database table.

 

Contents of .AZT file:

The contents/ different fields  of the :AZT files are: M2, K2, A2, P2, S2, D1, STD, BES.

How I proceeded:

1) Upload: Using GUI UPLOAD---> Successful

2) Defined a database table ZLT_AZTN with fields  M2, K2, A2, P2, S2, D1, STD, BES (ALL TYPE Character)

3) SPLIT .AZT file into different fields namely:  M2, K2, A2, P2, S2, D1, STD, BES. into an internal table itab--> Successful.

4) Saving data from this internal table (itab) to ZLT_AZTN (database table) by using MODIFY ---> Successful.

5) Now I want to pull the saved data from the database table ZLT_AZTN to an internal table and perform sum on the field "STD". where STD  represents "no of hours spend by employees on a project". ---> I am facing problem here during sum

As the data type of  field STD of the databse table ZLT_AZTN is of TYPE Character so during suem I am nit getting any result. The result shows blank.

As far as my knowledge is concerned, SUM can be used to sume fields of data type NUMC or DEC.

Dilema 1: Here if I define the field STD in ZLt_AZTN as TYPE DEC then I am not able to do the SPLIT.

Dilema2:  Here if I define the field STD in ZLt_AZTN as TYPE NUMC then I am able to do the SPLIT but in SUm I get "0000"..

One Possible Solution could be: TO MOVE the data from a database table ZLT_AZTN (All fields of TYPE CHARACTER) to another database table ZLT_AZTN1 (with all fields of Type Character except field STD as TYPE DEC). ---> For this I wrote a small code as below:

TYPES: Begin of ty_itab1,

    

         M2   TYPE Zlt_AZTN-M2,

         K2   TYPE Zlt_AZTN-K2,

         A2   TYPE Zlt_AZTN-A2,

         P2   TYPE Zlt_AZTN-P2,

         S2   TYPE Zlt_AZTN-S2,

         D1   TYPE Zlt_AZTN-D1,

         STD  TYPE Zlt_AZTN-STD,

         BES  TYPE Zlt_AZTN-BES,

     

      END of ty_itab1.

    

DATA: itab1 TYPE STANDARD TABLE OF ty_itab1.

  SELECT          M2

                  K2

                  A2

                  P2

                  S2

                  D1

                  STD

                  BES

         FROM     ZLT_AZTN1

         INTO     TABLE itab1.

MODIFY ZLT_AZTN1 FROM TABLE itab.

But on execution I get the following Error message;  "The type of the database table and work area (or internal table) "ITAB" are not Unicode convertible. Unicode convertible."

EXPERTS please provide me a solution.

Looking forward for valuable inputs.

Regards

Chandan Kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,364

Hi,

Declare one more internal table same as yours and declare STD as data type P, and for no.of hrs.

Example as below.

TYPES: Begin of ty_itab2,

   

         M2   TYPE Zlt_AZTN-M2,

         K2   TYPE Zlt_AZTN-K2,

         A2   TYPE Zlt_AZTN-A2,

         P2   TYPE Zlt_AZTN-P2,

         S2   TYPE Zlt_AZTN-S2,

         D1   TYPE Zlt_AZTN-D1,

         STD  TYPE P decimals 2,

         BES  TYPE Zlt_AZTN-BES,

    

      END of ty_itab2.

Then do loop

Loop itab1 into wa_itab1,

move-corresponding fields wa_itab1 into wa_itab2.

wa_itab2-STD = wa_itab1-std.

append wa_itab2 to itab2.

collect itab2.  

 

Endloop.

Dear Experts,

I am performing the folowing task:

1) To upload an .AZT file.

2) To SPLIT the data of this uploaded .AZT file at every ";"

3) Save this Splitted data to a data base table.

4) Now I want to perform Sum on one of the Data column of this database table.

 

Contents of .AZT file:

The contents/ different fields  of the :AZT files are: M2, K2, A2, P2, S2, D1, STD, BES.

How I proceeded:

1) Upload: Using GUI UPLOAD---> Successful

2) Defined a database table ZLT_AZTN with fields  M2, K2, A2, P2, S2, D1, STD, BES (ALL TYPE Character)

3) SPLIT .AZT file into different fields namely:  M2, K2, A2, P2, S2, D1, STD, BES. into an internal table itab--> Successful.

4) Saving data from this internal table (itab) to ZLT_AZTN (database table) by using MODIFY ---> Successful.

5) Now I want to pull the saved data from the database table ZLT_AZTN to an internal table and perform sum on the field "STD". where STD  represents "no of hours spend by employees on a project". ---> I am facing problem here during sum

As the data type of  field STD of the databse table ZLT_AZTN is of TYPE Character so during suem I am nit getting any result. The result shows blank.

As far as my knowledge is concerned, SUM can be used to sume fields of data type NUMC or DEC.

Dilema 1: Here if I define the field STD in ZLt_AZTN as TYPE DEC then I am not able to do the SPLIT.

Dilema2:  Here if I define the field STD in ZLt_AZTN as TYPE NUMC then I am able to do the SPLIT but in SUm I get "0000"..

One Possible Solution could be: TO MOVE the data from a database table ZLT_AZTN (All fields of TYPE CHARACTER) to another database table ZLT_AZTN1 (with all fields of Type Character except field STD as TYPE DEC). ---> For this I wrote a small code as below:

TYPES: Begin of ty_itab1,

    

         M2   TYPE Zlt_AZTN-M2,

         K2   TYPE Zlt_AZTN-K2,

         A2   TYPE Zlt_AZTN-A2,

         P2   TYPE Zlt_AZTN-P2,

         S2   TYPE Zlt_AZTN-S2,

         D1   TYPE Zlt_AZTN-D1,

         STD  TYPE Zlt_AZTN-STD,

         BES  TYPE Zlt_AZTN-BES,

     

      END of ty_itab1.

    

DATA: itab1 TYPE STANDARD TABLE OF ty_itab1.

  SELECT          M2

                  K2

                  A2

                  P2

                  S2

                  D1

                  STD

                  BES

         FROM     ZLT_AZTN1

         INTO     TABLE itab1.

MODIFY ZLT_AZTN1 FROM TABLE itab.

But on execution I get the following Error message;  "The type of the database table and work area (or internal table) "ITAB" are not Unicode convertible. Unicode convertible."

EXPERTS please provide me a solution.

Looking forward for valuable inputs.

Regards

Chandan Kumar

14 REPLIES 14
Read only

Former Member
0 Likes
2,364

Hi Chandan,

Instead of using another table to store the same redundant data, you can try the following approach, if it fulfills your requirement -

SELECT  *   FROM     ZLT_AZTN1    INTO     TABLE itab1.

Loop at itab1 into wa.

     lv_sum = lv_sum + wa-STD.

endloop.

write: lv_sum.

Regards,

Rachna

Read only

0 Likes
2,364

try this,

SELECT  *   FROM    ****  INTO     TABLE ITAB.

loop at itab into wa.

     lv_sum = lv_sum + wa-STD.

endloop.

Read only

0 Likes
2,364

Dear Rachan,

thanks for your reply. Do I need to define lv_sum? If yes how.

Regards

Chandan

Read only

0 Likes
2,364

Hi Chandan,

Of course you need to define lv_sum. Try putting it as int4 and also remember to define wa- structure of your table type.

Regards,

Rachna

Read only

Former Member
0 Likes
2,365

Hi,

Declare one more internal table same as yours and declare STD as data type P, and for no.of hrs.

Example as below.

TYPES: Begin of ty_itab2,

   

         M2   TYPE Zlt_AZTN-M2,

         K2   TYPE Zlt_AZTN-K2,

         A2   TYPE Zlt_AZTN-A2,

         P2   TYPE Zlt_AZTN-P2,

         S2   TYPE Zlt_AZTN-S2,

         D1   TYPE Zlt_AZTN-D1,

         STD  TYPE P decimals 2,

         BES  TYPE Zlt_AZTN-BES,

    

      END of ty_itab2.

Then do loop

Loop itab1 into wa_itab1,

move-corresponding fields wa_itab1 into wa_itab2.

wa_itab2-STD = wa_itab1-std.

append wa_itab2 to itab2.

collect itab2.  

 

Endloop.

Read only

0 Likes
2,364

Hi Rama,

thanks for your reply. I did what you suggested but the progg dumped at  move-corresponding in the below code.

Types:

     begin of ty_aztn1,

         m2   type zlt_aztn-m2,

         k2   type zlt_aztn-k2,

         a2   type zlt_aztn-a2,

         p2   type zlt_aztn-p2,

         s2   type zlt_aztn-s2,

         d1   type zlt_aztn-d1,

         std  type p decimals 2,

         bes  type zlt_aztn-bes,

      end of ty_aztn1.

DATA: it_aztn1      type standard table of ty_aztn1,

           wa_aztn1    type   ty_aztn1.

loop at it_aztn into wa_aztn.

      move-corresponding  wa_aztn to wa_aztn1.

      wa_aztn1-std = wa_aztn-std.

      append wa_aztn1 to it_aztn1.

    endloop.

Looking forward for a solution

Regards

Chandan

Read only

0 Likes
2,364

Can you please share complete code.

Please create two internal tables. one internal table should have the same old structure as you mentioned. then in second internal table, give the field with data type P where you require to capture number of hrs.

one itab is for fetching all data into your internal table.

Then loop the first internal table and try move each field into second internal table.

If you still have an issue, please do let me know,

Read only

0 Likes
2,364

Dear Rama,

Its a bit complicated one but I am sharing the complete code here:

*&---------------------------------------------------------------------*

*& Report  ZDEMO_ZEITERFASSUNG18

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  ZDEMO_ZEITERFASSUNG18.

TYPES: Begin OF ty_stdsatz,

               S1  TYPE Zlt_stdsatz-S1,

               S2  TYPE Zlt_stdsatz-S2,

             END OF ty_stdsatz,

        Begin OF ty_Mita,

                M1  TYPE Zlt_mita-M1,

                M2  TYPE Zlt_mita-M2,

        END OF ty_mita,

       Begin OF ty_kunde,

              K1  TYPE Zlt_kunde-K1,

              K2  TYPE Zlt_kunde-K2,

       END OF ty_kunde,

       Begin OF ty_Auftrag1,

         A1  TYPE Zlt_Auftrag1-A1,

         A2  TYPE Zlt_Auftrag1-A2,

         A3  TYPE Zlt_Auftrag1-A3,

         A4  TYPE Zlt_Auftrag1-A4,

         P1  TYPE Zlt_Auftrag1-P1,

         P2  TYPE Zlt_Auftrag1-P2,

         P3  TYPE Zlt_Auftrag1-P3,

       END OF ty_Auftrag1,

       Begin OF ty_AZTN,

         M2   TYPE Zlt_AZTN-M2,

         K2   TYPE Zlt_AZTN-K2,

         A2   TYPE Zlt_AZTN-A2,

         P2   TYPE Zlt_AZTN-P2,

         S2   TYPE Zlt_AZTN-S2,

         D1   TYPE Zlt_AZTN-D1,

         STD  TYPE Zlt_AZTN-STD,

         BES  TYPE Zlt_AZTN-BES,

       END OF ty_AZTN,

       Begin OF ty_AZT3,

         K2   TYPE ZLT_AZT3-K2,

         P2   TYPE ZLT_AZT3-P2,

         D1   TYPE Zlt_AZT3-D1,

         STD  TYPE Zlt_AZT3-STD,

         BES  TYPE Zlt_AZT3-BES,

      END OF ty_AZT3,

      Begin of ty_AZTN1,

         M2   TYPE Zlt_AZTN-M2,

         K2   TYPE Zlt_AZTN-K2,

         A2   TYPE Zlt_AZTN-A2,

         P2   TYPE Zlt_AZTN-P2,

         S2   TYPE Zlt_AZTN-S2,

         D1   TYPE Zlt_AZTN-D1,

         STD  TYPE P decimals 2,

         BES  TYPE Zlt_AZTN-BES,

      END OF ty_AZTN1,

      Begin OF ty_final,

         M1  TYPE Zlt_mita-M1,

         M2  TYPE Zlt_AZTN-M2,

         K1  TYPE Zlt_kunde-K1,

         K2  TYPE Zlt_AZTN-K2,

         A1  TYPE Zlt_Auftrag1-A1,

         A2  TYPE Zlt_AZTN-A2,

         A3  TYPE Zlt_auftrag1-A3,

         A4  TYPE Zlt_auftrag1-A4,

         P1  TYPE Zlt_auftrag1-P1,

         P2  TYPE Zlt_AZT-P2,

         S1  TYPE Zlt_stdsatz-S1,

         S2  TYPE Zlt_AZTN-S2,

         D1  TYPE Zlt_AZTN-D1,

         STD TYPE Zlt_AZTN-STD,

         BES TYPE Zlt_AZTN-BES,

      END OF ty_final.

       DATA: it_aztn       TYPE STANDARD TABLE OF ty_aztn with  header line,

             it_aztn1      TYPE STANDARD TABLE OF ty_aztn1,

             it_azt3       TYPE STANDARD TABLE OF ty_azt3,

             it_stdsatz    TYPE STANDARD TABLE OF ty_stdsatz,

             it_mita       TYPE STANDARD TABLE OF ty_mita,

             it_kunde      TYPE STANDARD TABLE OF ty_kunde,

             it_auftrag1   TYPE STANDARD TABLE OF ty_auftrag1,

             it_final      TYPE STANDARD TABLE OF ty_final.

      DATA:  wa_aztn     TYPE   ty_aztn,

             wa_aztn1    TYPE   ty_aztn1,

             wa_azt3     TYPE   ty_azt3,

             wa_stdsatz  TYPE   ty_stdsatz,

             wa_mita     TYPE   ty_mita,

             wa_kunde    TYPE   ty_kunde,

             wa_auftrag1 TYPE   ty_auftrag1,

             wa_final    TYPE   ty_final,

             wa_final1   TYPE   ty_final.

     PARAMETERS: P_Mitanr  TYPE   ZLT_AZTN-M2,

                 P_Datum   TYPE   ZLT_AZTN-D1.

         SELECT   M2

                  K2

                  A2

                  P2

                  S2

                  D1

                  STD

                  BES

         FROM     ZLt_AZTN

         INTO     TABLE it_AZTN

         Where    M2 = P_Mitanr

         AND      D1 = p_datum.

        IF sy-subrc <> 0.

     MESSAGE s000(ZAZT_01).

        ENDIF.

         SELECT   M1

                        M2

         FROM     ZLt_mita

         INTO       TABLE it_mita

         FOR        ALL ENTRIES IN it_aztn

         WHERE   M2 = it_AZTN-M2.

         SELECT   K1

                         K2

         FROM      Zlt_kunde

         INTO        TABLE it_kunde

         FOR         ALL ENTRIES IN it_aztn

         WHERE    K2 = it_AZTN-K2.

  SELECT   A1

                  A2

                  A3

                  A4

                  P1

                  P2

                  P3

         FROM     Zlt_auftrag1

         INTO     TABLE it_auftrag1

         FOR ALL ENTRIES IN it_AZTN

         WHERE    A2  = it_AZTN-A2

         AND      A3  = it_AZTN-K2

         AND      P2  = it_AZTN-P2.

         SELECT   S1

                  S2

         FROM     Zlt_stdsatz

         INTO     TABLE it_stdsatz

         FOR ALL ENTRIES IN it_AZTN

         WHERE    S2  = it_AZTN-S2.

         SELECT   K2

                  P2

                  D1

                  STD

                  BES

         FROM     Zlt_aztn

         INTO     TABLE it_azt3

         FOR ALL ENTRIES IN it_AZTN

         WHERE    D1  = it_AZTN-D1

         AND      K2  = it_AZTN-K2

         AND      P2  = it_AZTN-P2.

* the below LOOP is to move data from it_aztn tpo it_aztn1 as suggested by Rama which led to a dump

*    LOOP At it_aztn into wa_aztn.

*

*      MOVE-CORRESPONDING  wa_aztn TO wa_aztn1.

*      wa_aztn1-STD = wa_aztn-STD.

*      APPEND wa_aztn1 to it_aztn1.

*

*    ENDLOOP.

    LOOP At it_mita into wa_mita.

       Read table it_aztn    into wa_aztn    with key M2 = wa_mita-M2.

      If sy-subrc = 0.

        Clear: wa_final.

        MOVE-CORRESPONDING wa_mita     to wa_final.

        APPEND wa_final to it_final.

      ENDIF.

    ENDLOOP.

    LOOP At it_kunde into wa_kunde.

       Read table it_aztn    into wa_aztn    with key K2 = wa_kunde-K2.

      If sy-subrc = 0.

        Clear: wa_final.

        MOVE-CORRESPONDING wa_kunde     to wa_final.

        APPEND wa_final to it_final.

      ENDIF.

   ENDLOOP.

    LOOP At it_auftrag1 into wa_auftrag1.

       Read table it_aztn    into wa_aztn    with key K2 = wa_auftrag1-A3.

      If sy-subrc = 0.

        Clear: wa_final.

        MOVE-CORRESPONDING wa_auftrag1     to wa_final.

        APPEND wa_final to it_final.

      ENDIF.

    ENDLOOP.

    LOOP At it_azt3 into wa_azt3.

       Read table it_aztn    into wa_aztn    with key k2 = wa_azt3-k2.

      If sy-subrc = 0.

        Clear: wa_final.

        MOVE-CORRESPONDING wa_azt3     to wa_final.

        APPEND wa_final to it_final.

      ENDIF.

    ENDLOOP.

    LOOP At it_stdsatz into wa_stdsatz.

       Read table it_aztn    into wa_aztn    with key S2 = wa_stdsatz-S2.

      If sy-subrc = 0.

        Clear: wa_final.

        MOVE-CORRESPONDING wa_stdsatz     to wa_final.

        APPEND wa_final to it_final.

      ENDIF.

    ENDLOOP.



   LOOP At it_final into wa_final.

           wa_final1  =  wa_final.

    AT FIRST.

        WRITE: / sy-uline(240),

               / sy-vline,

                2 'Datum',

               12  sy-vline,

               14  'Mitarbeiter Name',

               36  sy-vline,

               38  'Kunde',

               50  sy-vline,

               52  'Auftrag',

               84  sy-vline,

               86  'Position',

              128  sy-vline,

              130  'Stunden',

              140  sy-vline,

              142  'Beschreibung',

              240  sy-vline.

   ENDAT.

       WRITE: / sy-uline(240),

               / sy-vline,

                2 wa_final-D1,

               12  sy-vline,

               14  wa_final-M1,

               36  sy-vline,

               38  wa_final-K1,

               50  sy-vline,

               52  wa_final-A1,

               84  sy-vline,

               86  wa_final-P1,

              128  sy-vline,

              130  wa_final1-STD,

              140  sy-vline,

              142  wa_final-BES,

              240  sy-vline.

  AT LAST.

      SUM.

      WRITE: / sy-uline(240),

               / sy-vline,

                2 'Stunden Summe',

              128  sy-vline,

              130  wa_final1-STD,

              140  sy-vline,

              240  sy-vline,

              / sy-uline(240).

  ENDAT.

  ENDLOOP.

When I had  uploaded the complete code then I think its the right time to ask one more doubt apart from the above persisting one.

ALSO I  want to select a range of date. How can I do that in PARAMETERS.

Ps: Rachna: How to introduce your code in the conrtrol-break in the above code.

Looking forward for your replies.

Regards

Chandan Kumar

Read only

0 Likes
2,364

Hi Chandan,

I am just providing you the part of your code where you can do the task required-

SELECT   K2

                  P2

                  D1

                  STD

                  BES

         FROM     Zlt_aztn

         INTO     TABLE it_azt3

         FOR ALL ENTRIES IN it_AZTN

         WHERE    D1  = it_AZTN-D1

         AND      K2  = it_AZTN-K2

         AND      P2  = it_AZTN-P2.

* the below LOOP is to move data from it_aztn tpo it_aztn1 as suggested by Rama which led to a dump

*    LOOP At it_aztn into wa_aztn.

*

*      MOVE-CORRESPONDING  wa_aztn TO wa_aztn1.

*      wa_aztn1-STD = wa_aztn-STD.

*      APPEND wa_aztn1 to it_aztn1.

*

*    ENDLOOP.


"code added

Data: lv_sum type int4.


LOOP At it_aztn into wa_aztn.

     lv_sum = lv_sum + wa_aztn-STD.

endloop.


write: lv_sum.

    LOOP At it_mita into wa_mita.

       Read table it_aztn    into wa_aztn    with key M2 = wa_mita-M2.

      If sy-subrc = 0.

        Clear: wa_final.

        MOVE-CORRESPONDING wa_mita     to wa_final.

        APPEND wa_final to it_final.

      ENDIF.

    ENDLOOP.

try the above code addition and see. It should work. And for getting a range for any field type you have to use Select Options-

SELECT-OPTIONS  : so_dt_rg    FOR sy-datum.

Regards,

Rachna

Read only

0 Likes
2,364

Hi Chandan,

Here is the sample code to sumup the values.

Output is

NAME ABC 35.00

I suggest you to check internal table initial or not whenever you use FOR ALL ENTRIES.

Regarding Range, use select-options provided in the above screen.

Read only

0 Likes
2,364

Hi Chandan,

Instead of using Move-corresponding,, move each fields one by one.Just Try it and see whether it works.

Regards,

Peri

Read only

0 Likes
2,364

Dear Rachana,

thanks for your reply again. I applied your code at the respective place suggested by you and also in

DATA: lv_sum  TYPE  int4.

LOOP at it_final into wa_final.

     wa_final1  =  wa_final.

     lv_sum  =   lv_sum  +   wa_final1-STD.

    

But in both cases it lead to a dump.

The error analysis in LOOP at it_final case says: The program attempted to interpret the value "02,50" as a number, but since the value contravenes the rules for correct number formats, this was not possible.

looking forward for you experts suggestioins and ideas.

Best regards

Chandan Kumar

Read only

0 Likes
2,364

Dear Rama,

Thanks for your suggestion. I did what you told but that also led to a dump. I moved like this:

TYPES: Begin OF ty_stdsatz,

         S1  TYPE Zlt_stdsatz-S1,

         S2  TYPE Zlt_stdsatz-S2,

       END OF ty_stdsatz,

       Begin OF ty_Mita,

         M1  TYPE Zlt_mita-M1,

         M2  TYPE Zlt_mita-M2,

       END OF ty_mita,

       Begin OF ty_kunde,

         K1  TYPE Zlt_kunde-K1,

         K2  TYPE Zlt_kunde-K2,

       END OF ty_kunde,

       Begin OF ty_Auftrag1,

         A1  TYPE Zlt_Auftrag1-A1,

         A2  TYPE Zlt_Auftrag1-A2,

         A3  TYPE Zlt_Auftrag1-A3,

         A4  TYPE Zlt_Auftrag1-A4,

         P1  TYPE Zlt_Auftrag1-P1,

         P2  TYPE Zlt_Auftrag1-P2,

         P3  TYPE Zlt_Auftrag1-P3,

       END OF ty_Auftrag1,

       Begin OF ty_AZTN,

         M2   TYPE Zlt_AZTN-M2,

         K2   TYPE Zlt_AZTN-K2,

         A2   TYPE Zlt_AZTN-A2,

         P2   TYPE Zlt_AZTN-P2,

         S2   TYPE Zlt_AZTN-S2,

         D1   TYPE Zlt_AZTN-D1,

         STD  TYPE Zlt_AZTN-STD,

         BES  TYPE Zlt_AZTN-BES,

       END OF ty_AZTN,

       Begin OF ty_AZT3,

         K2   TYPE ZLT_AZT3-K2,

         P2   TYPE ZLT_AZT3-P2,

         D1   TYPE Zlt_AZT3-D1,

         STD  TYPE Zlt_AZT3-STD,

         BES  TYPE Zlt_AZT3-BES,

      END OF ty_AZT3,

      Begin of ty_AZTN1,

         M2   TYPE Zlt_AZTN-M2,

         K2   TYPE Zlt_AZTN-K2,

         A2   TYPE Zlt_AZTN-A2,

         P2   TYPE Zlt_AZTN-P2,

         S2   TYPE Zlt_AZTN-S2,

         D1   TYPE Zlt_AZTN-D1,

         STD  TYPE P decimals 2,

         BES  TYPE Zlt_AZTN-BES,

      END OF ty_AZTN1,

      Begin OF ty_final,

         M1  TYPE Zlt_mita-M1,

         M2  TYPE Zlt_AZTN-M2,

         K1  TYPE Zlt_kunde-K1,

         K2  TYPE Zlt_AZTN-K2,

         A1  TYPE Zlt_Auftrag1-A1,

         A2  TYPE Zlt_AZTN-A2,

         A3  TYPE Zlt_auftrag1-A3,

         A4  TYPE Zlt_auftrag1-A4,

         P1  TYPE Zlt_auftrag1-P1,

         P2  TYPE Zlt_AZT-P2,

         S1  TYPE Zlt_stdsatz-S1,

         S2  TYPE Zlt_AZTN-S2,

         D1  TYPE Zlt_AZTN-D1,

*         STD TYPE Zlt_AZTN-STD, --> This was my previous declaration

         STD TYPE P  Decimals 2,--------> THIS IS THE DECLARATION THAT I DID AS PER UR                                                                    SUGGESTION

         BES TYPE Zlt_AZTN-BES,

      END OF ty_final.

       DATA: it_aztn       TYPE STANDARD TABLE OF ty_aztn with  header line,

             it_aztn1      TYPE STANDARD TABLE OF ty_aztn1,

             it_azt3       TYPE STANDARD TABLE OF ty_azt3,

             it_stdsatz    TYPE STANDARD TABLE OF ty_stdsatz,

             it_mita       TYPE STANDARD TABLE OF ty_mita,

             it_kunde      TYPE STANDARD TABLE OF ty_kunde,

             it_auftrag1   TYPE STANDARD TABLE OF ty_auftrag1,

*             it_position  TYPE STANDARD TABLE OF ty_position,

             it_final      TYPE STANDARD TABLE OF ty_final.

      DATA:  wa_aztn     TYPE   ty_aztn,

                  wa_aztn1    TYPE   ty_aztn1,

                  wa_azt3     TYPE   ty_azt3,

                  wa_stdsatz  TYPE   ty_stdsatz,

                  wa_mita     TYPE   ty_mita,

                  wa_kunde    TYPE   ty_kunde,

                  wa_auftrag1 TYPE   ty_auftrag1,

                  wa_final    TYPE   ty_final,

                  wa_final1   TYPE   ty_final.

     PARAMETERS: P_Mitanr  TYPE   ZLT_AZTN-M2,

                 P_Datum   TYPE   ZLT_AZTN-D1.

         SELECT   M2

                  K2

                  A2

                  P2

                  S2

                  D1

                  STD

                  BES

         FROM     ZLt_AZTN

         INTO     TABLE it_AZTN

         Where    M2 = P_Mitanr

         AND      D1 = p_datum.

        IF sy-subrc <> 0.

     MESSAGE s000(ZAZT_01).

        ENDIF.

         SELECT   M1

                        M2

         FROM     ZLt_mita

         INTO     TABLE it_mita

         FOR ALL ENTRIES IN it_aztn

         WHERE    M2 = it_AZTN-M2.

         SELECT   K1

                        K2

         FROM     Zlt_kunde

         INTO     TABLE it_kunde

         FOR ALL ENTRIES IN it_aztn

         WHERE    K2 = it_AZTN-K2.

   SELECT   A1

                  A2

                  A3

                  A4

                  P1

                  P2

                  P3

         FROM     Zlt_auftrag1

         INTO     TABLE it_auftrag1

         FOR ALL ENTRIES IN it_AZTN

         WHERE     A2  = it_AZTN-A2

         AND      A3  = it_AZTN-K2

         AND      P2  = it_AZTN-P2.

   SELECT   S1

                  S2

         FROM     Zlt_stdsatz

         INTO     TABLE it_stdsatz

         FOR ALL ENTRIES IN it_AZTN

         WHERE    S2  = it_AZTN-S2.

   SELECT   K2

                  P2

                  D1

                  STD

                  BES

         FROM     Zlt_aztn

         INTO     TABLE it_azt3

         FOR ALL ENTRIES IN it_AZTN

         WHERE    D1  = it_AZTN-D1

         AND      K2  = it_AZTN-K2

         AND      P2  = it_AZTN-P2.

    LOOP At it_mita into wa_mita.

       Read table it_aztn    into wa_aztn    with key M2 = wa_mita-M2.

      If sy-subrc = 0.

        Clear: wa_final.

        MOVE-CORRESPONDING wa_mita     to wa_final.

        APPEND wa_final to it_final.

      ENDIF.

    ENDLOOP.

    LOOP At it_kunde into wa_kunde.

       Read table it_aztn    into wa_aztn    with key K2 = wa_kunde-K2.

      If sy-subrc = 0.

        Clear: wa_final.

        MOVE-CORRESPONDING wa_kunde     to wa_final.

        APPEND wa_final to it_final.

      ENDIF.

   ENDLOOP.

    LOOP At it_auftrag1 into wa_auftrag1.

       Read table it_aztn    into wa_aztn    with key K2 = wa_auftrag1-A3.

      If sy-subrc = 0.

        Clear: wa_final.

        MOVE-CORRESPONDING wa_auftrag1     to wa_final.

        APPEND wa_final to it_final.

      ENDIF.

    ENDLOOP.

    LOOP At it_azt3 into wa_azt3.

       Read table it_aztn    into wa_aztn    with key k2 = wa_azt3-k2.

      If sy-subrc = 0.

        Clear: wa_final.

        MOVE-CORRESPONDING wa_azt3     to wa_final.

        wa_final-STD  = wa_azt3-STD.         -----------------------------> THIS STEP I DID AS PER UR SUGGESTION

        APPEND wa_final to it_final.

      ENDIF.

    ENDLOOP.

    LOOP At it_stdsatz into wa_stdsatz.

       Read table it_aztn    into wa_aztn    with key S2 = wa_stdsatz-S2.

      If sy-subrc = 0.

        Clear: wa_final.

        MOVE-CORRESPONDING wa_stdsatz     to wa_final.

        APPEND wa_final to it_final.

      ENDIF.

    ENDLOOP.

   LOOP At it_final into wa_final.

           wa_final1  =  wa_final.


    AT FIRST.

        WRITE: / sy-uline(240),

               / sy-vline,

                2 'Datum',

               12  sy-vline,

               14  'Mitarbeiter Name',

               36  sy-vline,

               38  'Kunde',

               50  sy-vline,

               52  'Auftrag',

               84  sy-vline,

               86  'Position',

              128  sy-vline,

              130  'Stunden',

              140  sy-vline,

              142  'Beschreibung',

              240  sy-vline.

   ENDAT.

       WRITE: / sy-uline(240),

               / sy-vline,

                2 wa_final-D1,

               12  sy-vline,

               14  wa_final-M1,

               36  sy-vline,

               38  wa_final-K1,

               50  sy-vline,

               52  wa_final-A1,

               84  sy-vline,

               86  wa_final-P1,

              128  sy-vline,

              130  wa_final1-STD,

              140  sy-vline,

              142  wa_final-BES,

              240  sy-vline.

  AT LAST.

*      Sum.                                      -------> This is what I did earlier

      Collect wa_final  into it_final.     ---------> This is what I did as per YOUR Suggestion.

      WRITE: / sy-uline(240),

               / sy-vline,

                2 'Stunden Summe',

              128  sy-vline,

              130  wa_final1-STD,

              140  sy-vline,

              240  sy-vline,

              / sy-uline(240).

  ENDAT.

  ENDLOOP.



Please provide me a SOLUTION.


STILL LOOKING FORWARD FOR A SOLUTION.


Best Regards

Chandan Kumar

Read only

0 Likes
2,364

Dear Rachna and all,

Your suggestions were correct. Finally I found where the mistake was. As in Germany we follow ',' instead of '.' for decimals. This was leading to a dump even though I applied Rachna#s code and also code suggested by other experts out here.

Thanks to all .

Regards

Chandan