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: 

Concatenate sy-title and sy-dbcnt to Display in Title Bar

keega1
Participant
0 Kudos

Hi there!

I'm curious if anyone has concatenated sy-title and sy-dbcnt to display in the title bar.

When one of these reports are chosen and executed:

the button selection name and row count should be displayed:

This is what I currently have to display the chosen selection:

START-OF-SELECTION.  "to set it once list is displayed

   IF P_RAD1 = 'X'.
    sy-title = 'SAP GUI'(001).
      ELSE. P_RAD2 = 'X'.
      sy-title = 'CDS View'(002).
      ENDIF.

END-OF-SELECTION.

What is the best way of going about this?

Thank you in advance!

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

Something like this? Prefer SET TITLEBAR and do not change system fields.

CASE 'X'.
  WHEN P_RAD1.
    title = |{ sy-dbcnt }|.
    SET TITLEBAR 'YOURBAR1' WITH title.
  WHEN P_RAD2.
    title = |{ sy-dbcnt }|.
    SET TITLEBAR 'YOURBAR2' WITH title.
ENDCASE.

A title bar is a subobject of program, like dynpro, GUI status, text element...

The title bar YOURBAR1 would contain the title 'SAP GUI &1', and &1 is replaced at run time by the first text after WITH.

21 REPLIES 21

Former Member
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since you're new in asking questions here, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members. For example, you can outline what steps you took to find answers (and why they weren't helpful), share screenshots of what you've seen/done, make sure you've applied the appropriate tags, and use a more descriptive subject line. The more details you provide, the more likely it is that members will be able to assist you. You should also make sure you're using all the appropriate tags, so the right experts can find your question.

Should you wish, you can revise your question now by selecting Actions, then Edit.

Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS . By personalizing your profile with a photo of you, you encourage readers to respond.

Best regards,

Mariah

SAP Community moderator

Sandra_Rossi
Active Contributor

Something like this? Prefer SET TITLEBAR and do not change system fields.

CASE 'X'.
  WHEN P_RAD1.
    title = |{ sy-dbcnt }|.
    SET TITLEBAR 'YOURBAR1' WITH title.
  WHEN P_RAD2.
    title = |{ sy-dbcnt }|.
    SET TITLEBAR 'YOURBAR2' WITH title.
ENDCASE.

A title bar is a subobject of program, like dynpro, GUI status, text element...

The title bar YOURBAR1 would contain the title 'SAP GUI &1', and &1 is replaced at run time by the first text after WITH.

0 Kudos

Hi Sandra,

Thank you for responding.

I think something like that would work. You "piped" it! That's very cool, and I do think it is valid. I'll give it a shot.

This is what I was attempting with before:

DATA: title(10) TYPE C VALUE 'SAPPY GUI',rowcount TYPE N,sep,destination(50) TYPE C.CONCATENATE title rowcount INTO destination SEPARATED BY sep.WRITE destination.

It didn't work as expected.

Thanks!

0 Kudos

CONCATENATE needs character fields.

Try the String Template:

destination = |{ title } { rowcount }|.

0 Kudos

I tried using the example suggested:

*CASE 'X'.
*  WHEN P_RAD1.
*    SET TITLEBAR 'SAP GUI' WITH |{ sy-dbcnt }|.
*  WHEN P_RAD2.
*    SET TITLEBAR 'CDS View' WITH |{ sy-dbcnt }|.
*ENDCASE.

and it doesn't like the pipes. I'm using SAP 760 as far as I can tell.

Tried this (template) as well as just a test, and I cannot get it to use sy-title and sy-dbcnt

DATA: title(10)       TYPE C VALUE 'SAPPY GUI',
*      rowcount        TYPE N,
*      sep,
*      destination(50) TYPE C.
*
*CONCATENATE title rowcount INTO destination SEPARATED BY sep.
*WRITE destination.

Here's my entire program:

*&---------------------------------------------------------------------*
*& Report Z_SELECTEX_IG
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z_SELECTEX_IG.

TABLES: MARA,
        MAKT,
        ZISELECTEXIG.

*& SELECTION SCREEN AND SELECT OPTIONS FOR USER INPUT

SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-003.
PARAMETERS: P_RAD1 RADIOBUTTON GROUP RAD DEFAULT 'X' USER-COMMAND flag, "/ SAP GUI
            P_RAD2 RADIOBUTTON GROUP RAD.                               "/ CDS View
SELECTION-SCREEN END OF BLOCK BLK1.

SELECT-OPTIONS: mats FOR mara-matnr OBLIGATORY.

TYPES:
BEGIN OF itab,
  matnr TYPE mara-matnr,
  matkl TYPE mara-matkl,
*  maktx TYPE makt-maktx,
  meins TYPE mara-meins,
  mtart TYPE mara-mtart,
END OF itab.

*& Initialization of Events
*DATA: title(10)       TYPE C VALUE 'SAPPY GUI',
*      rowcount        TYPE N,
*      sep,
*      destination(50) TYPE C.
*
*CONCATENATE title rowcount INTO destination SEPARATED BY sep.
*WRITE destination.
*ULINE.

INITIALIZATION.
*mats-low = ''.
*mats-high = ''.

APPEND mats.
AT SELECTION-SCREEN.
  IF mats-low = ' '.
    MESSAGE I000(ZKMESSAGE).
    ELSEIF mats-high = ' '.
      MESSAGE I001(ZKMESSAGE).
      ENDIF.

*& TOP OF PAGE EVENT
TOP-OF-PAGE.
SET TITLEBAR sy-title.
*WRITE: /20 'List:', SY-DBCNT CENTERED.
ULINE.
END-OF-PAGE.

TYPE-POOLS: slis.                               " SLIS contains all the ALV data types

*& Data Declaration

*DATA: it_mara     TYPE TABLE OF mara.

DATA: it_fieldcat  TYPE slis_t_fieldcat_alv,
      wa_fieldcat  TYPE slis_fieldcat_alv.

DATA: BEGIN OF it_mara OCCURS 0,
  matnr LIKE mara-matnr,
  maktx LIKE makt-maktx,
  meins LIKE mara-meins,
  mtart LIKE mara-mtart,
END OF it_mara.

*& START-OF-SELECTION
*INITIALIZATION.       "to set titlebar on selection screen
*   sy-title = sy-dbcnt.

START-OF-SELECTION.

*Fetching data from database - playing with relational operators and aliases

IF P_RAD1 = 'X'.
  SELECT mr~matnr, mk~maktx, mr~meins, mr~mtart
    FROM mara as mr inner join makt as mk on mr~matnr eq mk~matnr
      INTO TABLE @it_mara WHERE mr~matnr IN @mats.
*  SELECT mara~matnr, maktx, meins, mtart FROM mara
*      INNER JOIN makt on makt~matnr = mara~matnr
*      INTO TABLE @it_mara
*      WHERE matnr IN @mats.
*    SELECT mara~matnr, meins, mtart FROM mara
*      INTO TABLE @it_mara
*      WHERE matnr IN @mats.
  ELSEIF P_RAD2 = 'X'.
    SELECT * FROM ZI_SELECTEXIG
      INTO TABLE @it_mara.
ENDIF.

INITIALIZATION.       "to set titlebar on selection screen

START-OF-SELECTION.  "to set it once list is displayed
   IF P_RAD1 = 'X'.
    sy-title = 'SAP GUI'(001).
      ELSE. P_RAD2 = 'X'.
      sy-title = 'CDS View'(002).
      ENDIF.
END-OF-SELECTION.

CONCATENATE:('sy-title', 'sy-dbcnt').

*CASE 'X'.
*  WHEN P_RAD1.
*    SET TITLEBAR 'SAP GUI' WITH |{ sy-dbcnt }|.
*  WHEN P_RAD2.
*    SET TITLEBAR 'CDS View' WITH |{ sy-dbcnt }|.
*ENDCASE.

*Build field catalog

  wa_fieldcat-fieldname  = 'MATNR'.             " Fieldname in the data table - Material Number
  wa_fieldcat-seltext_m  = 'MaterialNumber'.   " Column description in the output
  APPEND wa_fieldcat TO it_fieldcat.            " Append work area to internal table

  wa_fieldcat-fieldname  = 'MAKTX'.             " Fieldname in the data table - Material Description
  wa_fieldcat-seltext_m  = 'MaterialDesc'.     " Column description in the output
  APPEND wa_fieldcat TO it_fieldcat.            " Append work area to internal table

  wa_fieldcat-fieldname  = 'MEINS'.             " Fieldname in the data table - Base Unit of Measure
  wa_fieldcat-seltext_m  = 'Unit'.              " Column description in the output
  APPEND wa_fieldcat TO it_fieldcat.            " Append work area to internal table

  wa_fieldcat-fieldname  = 'MTART'.             " Fieldname in the data table - Material
  wa_fieldcat-seltext_m  = 'MaterialType'.    " Column description in the output
  APPEND wa_fieldcat TO it_fieldcat.            " Append work area to internal table

*Pass data and field catalog to ALV function module to display ALV list

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      it_fieldcat   = it_fieldcat
    TABLES
      t_outtab      = it_mara
    EXCEPTIONS
      program_error = 1
      OTHERS        = 2.

Any help would be greatly appreciated!

Thank you!

0 Kudos
title = |{ sy-dbcnt }|.
SET TITLEBAR 'SAP GUI' WITH title.

0 Kudos

I see that your program still uses the old code (sy-title), forbidden as I explained earlier. Any reason?

0 Kudos

I must have missed the "forbidden" part? I still don't see it.

No reason other than being new and not knowing what the heck I'm doing half of the time. It seems such a simple thing to be able to do, but I cannot find anything that I can reference online that makes sense (or works).

Still looking.

Thanks!

0 Kudos

I don't understand where you are stuck. Create 2 title bars named YOURBAR1 and YOURBAR2. Did you find out how to create the "title bar" object? As you are a beginner, you have to explain everything you do, and tell about everything you do not understand in the answers.

And during the PBO, do that:

CASE 'X'.
  WHEN P_RAD1.
    title = |{ sy-dbcnt }|.
    SET TITLEBAR 'YOURBAR1' WITH title.
  WHEN P_RAD2.
    title = |{ sy-dbcnt }|.
    SET TITLEBAR 'YOURBAR2' WITH title.
ENDCASE.

NB: forbidden part = "do not change system fields" i.e. do not change sy-title.

0 Kudos

PS: I guess ABAP 7.60 doesn't exist. SAP GUI for Windows 7.60 exists. But it's not the ABAP version -> look at menu System > Status, software component SAP_ABA.

0 Kudos

Using the CASE stmt:

CASE 'X'.
      WHEN P_RAD1.
    SET TITLEBAR 'SAP GUI' WITH |{ sy-dbcnt }|.
      WHEN P_RAD2.
      SET TITLEBAR 'CDS View' WITH |{ sy-dbcnt }|.
      ENDCASE.

and I get this error:

I find it hard to believe that the pipe isn't recognized, but perhaps I'm doing something wrong.

Any thoughts?

0 Kudos

Please look twice at the code of my last comment. I correct the code of the main answer.

matt
Active Contributor
0 Kudos

It's not SAP Gui vs CDS, it's OpenSQL vs SDS. OpenSQL is part of the ABAP language. It can be programmed in the SAP GUI environment or eclipse. CDS can only be programmed in eclipse.

keega
Participant
0 Kudos

Hi Matthew, those are just "placeholders" if you would. They simply denote from which side the resulting report came from: The SAPGUI was created using the ABAP editor, while the CDS View was created using Eclipse.

Thanks!

keega1
Participant
0 Kudos

Thanks!

I did change the code and now I'm getting "Field TITLE is unknown."

I'll continue to work on it.

Thanks again, I appreciate your time.

CASE 'X'.
  WHEN P_RAD1.
    title = |{ sy-dbcnt }|.
    SET TITLEBAR 'SAP GUI&1' WITH title.
  WHEN P_RAD2.
    title = |{ sy-dbcnt }|.
    SET TITLEBAR 'CDS View&1' WITH title.
ENDCASE.

Fixed that "rookie" error about "title" not being known. Just trying to get it to display. Seems to be ignoring it 😉

Sandra_Rossi
Active Contributor
0 Kudos

Please use COMMENT button. The button ANSWER is only to propose solution (see "before answering").

Sandra_Rossi
Active Contributor
0 Kudos

It seems that you didn't understand that a Title Bar is an object to be created, like a dynpro, not a free text. Look at the ABAP documentation and all its executable examples. That will save you a lot of time!

0 Kudos

Thank you, Sandra, I will. I'm a couple weeks new at this so my apologies for being a bit of a dork 🙂

keega1
Participant

Sandra, this is great. Once i got past my own errors, I got it to work with your example.

and:

I think I have a length constraint here. I will fix it. BUT IT WORKS! Thank you!

Sandra_Rossi
Active Contributor
0 Kudos

Please use COMMENT button. The button ANSWER is only to propose solution (see "before answering").