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

Abap code issue

Former Member
0 Likes
1,026

Hi Abap experts,

I found this Abap code, but since it contains no comments. I can’t understand what it really does.

At a guess. It manages a query with lines and columns axis.

Thanks for your help.

Amine

-----------------------------------------------------------------------------------------------

LOOP AT tn_cell_data INTO wa_cell_data.

w_col
= wa_cell_data-cell_ordinal MOD w_tfill.
w_lig
= wa_cell_data-cell_ordinal DIV w_tfill.

CASE w_col.
WHEN 0.
wa_fic_abc
-w_phase = 'AB'.
CONCATENATE wa_tvarvc-low(4) '.' wa_tvarvc-low+5(2) INTO wa_fic_abc-w_exercice.
wa_fic_abc
-w_period = wa_fic_abc-w_exercice.
wa_fic_abc
-w_flux = 'AA'.

CLEAR w_mnt5dec.
w_mnt5dec
= wa_cell_data-value / 1000.
wa_fic_abc
-w_montant = w_mnt5dec.
IF wa_fic_abc-w_montant+17(1) = '-'.
wa_fic_abc
-w_montant+17(1) = ' '.
CONDENSE wa_fic_abc-w_montant.
CONCATENATE '-' wa_fic_abc-w_montant INTO wa_fic_abc-w_montant.
ELSE.
CONDENSE wa_fic_abc-w_montant.
ENDIF.

READ TABLE tn_ligne INTO wa_ligne
WITH KEY tuple_ordinal = w_lig BINARY SEARCH.

IF sy-subrc EQ 0.
LOOP AT tn_ligne INTO wa_ligne FROM sy-tabix.
IF wa_ligne-tuple_ordinal NE w_lig.
EXIT.
ENDIF.
CASE wa_ligne-chanm.
WHEN '0COMP_CODE__0COMPANY'.
wa_fic_abc
-w_unite = wa_ligne-chavl_ext.
WHEN 'Y_ABCACCNT'.
wa_fic_abc
-w_rubrique = wa_ligne-chavl_ext.
WHEN '0PROFIT_CTR__BUSINESS'.
wa_fic_abc
-w_bu = wa_ligne-chavl_ext.
WHEN 'TRADING__PARTNER'.
wa_fic_abc
-w_tiers = wa_ligne-chavl_ext.
WHEN '0LOC_CURRCY' OR '0LOC_CURRC2'.
wa_fic_abc
-w_dev_fil = wa_ligne-chavl_ext.
WHEN '0DOC_CURRCY'.
wa_fic_abc
-w_dev_tr = wa_ligne-chavl_ext.
ENDCASE.
ENDLOOP.
ENDIF.
WHEN 1.
CLEAR w_mnt5dec.
w_mnt5dec
= wa_cell_data-value / 1000.
wa_fic_abc
-w_montant_tr = w_mnt5dec.
IF wa_fic_abc-w_montant_tr+17(1) = '-'.
wa_fic_abc
-w_montant_tr+17(1) = ' '.
CONDENSE wa_fic_abc-w_montant_tr.
CONCATENATE '-' wa_fic_abc-w_montant_tr INTO wa_fic_abc-w_montant_tr.
ELSE.
CONDENSE wa_fic_abc-w_montant_tr.
ENDIF.


1 ACCEPTED SOLUTION
Read only

gouravkumar64
Active Contributor
0 Likes
991

Hi,

What is your problem? what u want? In which place u r using this?

Thanks

Gourav.

7 REPLIES 7
Read only

gouravkumar64
Active Contributor
0 Likes
992

Hi,

What is your problem? what u want? In which place u r using this?

Thanks

Gourav.

Read only

0 Likes
991

Hi Gourav,

This program is used on BW (T-Code SE38) in order to generate a CSV file with some calulations.

It calls a Business Explorer Query (Analysing columns by lines)

There are no comments on the code. So it's not easy to understand what it does.

What I want to espcially understand is :

w_col = wa_cell_data-cell_ordinal MOD w_tfill. --> Why this calculation??

Why is he using figures 0 and 1 on When after w_col.

Thanks.

Amine

Read only

0 Likes
991

Hi Amine,

Your question is bit vague.

But you want to know about the MOD action:

MOD will give you the integral remainder of the division of the left by the right operand.

So w_tfill maybe of  value 2. So that it can be used to work on the odd values and even values of the columns i guess.

Try to clarify the question.

Regards,

Akhil

Read only

0 Likes
991

Hi Akhil,

Thanks for your answer. In fact you're right. In debbugging mode I am getting w_tfill = 2.

To clarify my question. I will focus on this line:

w_col = wa_cell_data-cell_ordinal MOD w_tfill

Below an extract from TN_CELL_DATA

That means that w_col would be equal to all values contained in column cell_ordinal MOD w_t_fill? why?

Thanks.

Amine

Read only

0 Likes
991

Hi Amine,

Nicely clarified.

w_col wont have all the values.

The whole code that you put here is inside the loop tn_cell_data to the work area wa_cell_data.

So in each step of the loop, each record of the tn_cell_data will be moved to wa_cell_data for manipulation.

So in first step

wa_cell_data-cell_ordinal = 000000.

w_tfill = 2.

So w_col will be equal to 0.

In second step

wa_cell_data-cell_ordinal = 000001.

w_tfill = 2.

So w_col will be equal to 1.

So they are clearly trying to work on the alternative records.

Mostly before closing the loop, they will be clearing the value in the workarea, wa_cell_data

But i'm afraid to assure on the working of the code as am not at all aware of the context.

Regards,

Akhil

Read only

0 Likes
991

Hi,

This code seems to build a transposed view of TN_CELL_DATA and TN_LIGNE into a new table of structure WA_FIC_ABC.

Maybe it would be clearer if we can have the declaration part of those objects.

Basically, W_COL will always contain the value 0 or 1, hence both WHEN statements. While W_LIG will successively points to higher indexes in table TN_LIG by  pair (0, 0, 1, 1, 2, 2, ...).

Kr,

Manu.

Read only

0 Likes
991

Hi Akhil and Manu,

Thanks for your explanations.

Below the declaration part:

DATA:

tn_cell_data TYPE rrws_t_cell,

tn_axis_data TYPE rrws_thx_axis_data,

wa_cell_data TYPE LINE OF rrws_t_cell,

wa_axis_data TYPE LINE OF rrws_thx_axis_data,

tn_ligne TYPE rrws_tx_set,

wa_ligne TYPE LINE OF rrws_tx_set,

tn_colonne TYPE rrws_tx_set,

wa_colonne TYPE LINE OF rrws_tx_set.

DATA: w_tfill LIKE sy-tfill,

       w_lig TYPE i,

       w_col TYPE i.

The code is so long and there is no comments. So it's a nightmare to understand it

Thanks.

Amine