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: 

Adding a function module into a SQ01 Query

0 Kudos

Hi ABAP Gurus,

I was trying to extract few dates from TSEGE Table, by linking the VTTK - HANDLE. We are trying to look at maintaining dates of shipment that were not previously used in our company.

When I tried extracting the dates from TSEGE, they come as timestamped UTC. I was told to use the function module IB_CONVERT_FROM_TIMESTAMP with CET in a query by an external consultant we use for our services. I am familiar with creating simple queries in SQVI and convert them to SQ01, also I know to create queries in SQ01 itself. But do not know how to add a function module into an SQ01 Query.

After checking a few threads, I realise that I should be creating a field and entering the code of the function module.

Is there any way, anybody could instruct me in simple terms how do I go about adding a function module.

Your help will be greatly appreciated.

Thanks in advance!

1 ACCEPTED SOLUTION

jogeswararao_kavala
Active Contributor
0 Kudos

First you need to create an Infoset (SQ02). Here you will have your Additional field to hold the converted time. Following is an example of using FM in an Infoset (SQ02). Here first we created an Additional field mnthr in the Extras tab and gave the FM code shown in the coding section of this Additional field..

Take this Additional field into FieldGroups of the Infoset along with other fields of your report. Generate Infoset.  Now you will create an Infoset Query (SQ01) based on this Infoset, where this calculted Additiona filed will be available to you.

Jogeswara Rao K

7 REPLIES 7

Former Member
0 Kudos

Hi Dsouza,

you can add any FM or code in SQ02 infoset area not in SQ01.

when you convert your query in SQ01 then tat time system  should be having infoset SQ02 .

you can go  with your infoset in SQ02 and add  code in  inside SQ02 for validation  or updating/adding new fields in infoset  etc.

Please check and let us know if you have any doubt.

Regards,

Prasenjit

jogeswararao_kavala
Active Contributor
0 Kudos

First you need to create an Infoset (SQ02). Here you will have your Additional field to hold the converted time. Following is an example of using FM in an Infoset (SQ02). Here first we created an Additional field mnthr in the Extras tab and gave the FM code shown in the coding section of this Additional field..

Take this Additional field into FieldGroups of the Infoset along with other fields of your report. Generate Infoset.  Now you will create an Infoset Query (SQ01) based on this Infoset, where this calculted Additiona filed will be available to you.

Jogeswara Rao K

0 Kudos

Dear Jogeswara,

I have after reading a few threads, understood this small code and changed to my specification

To convert UTC Start time from TSEGE

CALL FUNCTION 'IB_CONVERT_FROM_TIMESTAMP'

  EXPORTING

    I_TIMESTAMP = TSEGE-EVEN_TSTFR

    I_TZONE = CET

  IMPORTING

    e_datlo = date

    e_timlo = time

To convert UTC Start End from TSEGE

CALL FUNCTION 'IB_CONVERT_FROM_TIMESTAMP'

  EXPORTING

    i_timestamp = TSEGE-EVEN_TSTTO

    i_tzone = CET

  IMPORTING

    e_datlo = date

    e_timlo = time

I hope the above codes are correct. If yes, I have a doubt: TSEGE-EVEN_TSTFR & TSEGE-EVEN_TSTTO have different time in the same field, "Actual" & "Forecast", which is determined by TSEGE-EVEN_VERTY wherein 1 is Actual and 0 is Forecast. Is this something I would have to put in the code, or something that would work in the query "Selection Fields"?

Thanks again!

0 Kudos

You may have to manage through if condition like

If TSEGE-EVEN_VERTY = '1'.

Call function .....

...........

...........

else.

Call Function ....

...........

...........

Endif.

0 Kudos

If TSEGE-EVEN_VERTY = '1'.

CALL FUNCTION 'IB_CONVERT_FROM_TIMESTAMP'.

   EXPORTING

     i_timestamp = TSEGE-EVEN_TSTFR.

     i_tzone = CET.

   IMPORTING

     e_datlo = date.

     e_timlo = time.

else

CALL FUNCTION 'IB_CONVERT_FROM_TIMESTAMP'.

   EXPORTING

     i_timestamp = TSEGE-EVEN_TSTFR.

     i_tzone = CET.

   IMPORTING

     e_datlo = date.

     e_timlo = time.

Endif.

Is the above fine now?

0 Kudos

Yes I am hinting at htat only. Rest take care of syntax.

But there is soemthing wrong. You have put same field value (TSEGE-EVEN_TSTFR) at both the CALL FUNCTION

0 Kudos

The problem is TSEGE-EVEN_TSTFR holds both the values, Actual and Forecast and is differentiated by

TSEGE-EVEN_VERTY = '1'. or TSEGE-EVEN_VERTY = '0'.


So in this case, I cannot use, IF I will have to use "When"