cancel
Showing results for 
Search instead for 
Did you mean: 

SAP SCRIPT: Header text not printing - Custom Purchase Order.

Former Member
0 Kudos

Hello Experts,

I have used the standard MEDRUCK and copied to ZMEDRUCK. I want the PO header text to print in my form.

I have used subroutine-pool and called it in the form.

Here is my subroutine

FORM fetch_table_data TABLES in_tab STRUCTURE itcsy
                             out_tab STRUCTURE itcsy.
  TABLES EKKO.

  DATA: BEGIN OF header OCCURS 0,
          ld_txt1(163),
          ld_txt2(163),
          ld_txt3(163),
        END OF header.

  DATA: li_lines LIKE STANDARD TABLE OF tline WITH HEADER LINE,
        ID like THEAD-TDID,
        TNAME LIKE THEAD-TDNAME,
        TDOBJECT like THEAD-TDOBJECT.

  DATA  HTEXT LIKE EKKO-EBELN.
*  HTEXT = EKKO-EBELN.

  READ TABLE in_tab WITH KEY EKKO-EBELN.
  if sy-subrc = 0.
  TNAME = in_tab-value.
  ENDIF.

TNAME = EKKO-EBELN.
*CONCATENATE EKPO-ebeln EKPO-ebelp INTO v_item_text.
*MOVE v_head_text to HNAME.

CALL FUNCTION 'READ_TEXT'
  EXPORTING
*   CLIENT                        = SY-MANDT
    id                            = 'F01'
    language                      = 'E'
    name                          = TNAME
    object                        = 'EKKO'
*   ARCHIVE_HANDLE                = 0
*   LOCAL_CAT                     = ' '
* IMPORTING
*   HEADER                        = TNAME
  tables
    lines                         = li_lines
 EXCEPTIONS
   ID                            = 1
   LANGUAGE                      = 2
   NAME                          = 3
   NOT_FOUND                     = 4
   OBJECT                        = 5
   REFERENCE_CHECK               = 6
*   WRONG_ACCESS_TO_ARCHIVE       = 7
*   OTHERS                        = 8
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CLEAR out_tab.
out_tab-VALUE = TNAME.
CONDENSE out_tab-VALUE.
MODIFY out_tab TRANSPORTING VALUE WHERE NAME = 'TNAME'.


ENDFORM.

And my script in the form is

PERFORM FETCH_TABLE_DATA IN PROGRAM ZMEDRUCK_SUBP2
USING &EKKO-EBELN&
CHANGING &TNAME&
ENDPERFORMpar RECEIVED FROM M/S	&TNAME&

The header text is still not flowing in my form.

What mistake i'm I doing here ?

How can I resolve this ?

Pls help !

Accepted Solutions (1)

Accepted Solutions (1)

nayan_sahu
Explorer
0 Kudos

Hi,

Data is li_lines internal table. 1st you have to read the text form the internal table line by sy-tabix.

At last you have to concatenate these variable into the out tab value.

you can use the following code

ORM fetch_table_data TABLES in_tab STRUCTURE itcsy

out_tab STRUCTURE itcsy.

TABLES EKKO.

DATA: BEGIN OF header OCCURS 0,

ld_txt1(163),

ld_txt2(163),

ld_txt3(163),

END OF header.

DATA: li_lines LIKE STANDARD TABLE OF tline WITH HEADER LINE,

ID like THEAD-TDID,

TNAME LIKE THEAD-TDNAME,

TDOBJECT like THEAD-TDOBJECT.

DATA HTEXT LIKE EKKO-EBELN.

READ TABLE in_tab WITH KEY EKKO-EBELN.

if sy-subrc = 0.

TNAME = in_tab-value.

ENDIF.

ALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

id = 'F01'

language = 'E'

name = TNAME

object = 'EKKO'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

tables

lines = li_lines

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

  • WRONG_ACCESS_TO_ARCHIVE = 7

  • OTHERS = 8

.

IF sy-subrc 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

data : f_lines TYPE i,

DESCRIBE TABLE li_lines LINES f_lines.

data: lstr type String,

lstr1 type string,

lstr2 type string,

lstr3 type string,

lstr4 type string.

read table li_lines index 1.

lstr = li_lines

condense lstr.

clear li_lines

read table li_lines index 2.

lstr1 = li_lines

condense lstr.

clear li_lines

read table li_lines index 3.

lstr2 = li_lines

condense lstr.

clear li_lines

if f_lines GT 3.

ead table li_lines index 4.

lstr3 = li_lines

condense lstr.

clear li_lines

ead table li_lines index 5.

lstr4 = li_lines

condense lstr.

clear li_lines

endif.

data : v_text type text.

concatenate lstr1 lstr2 lstr3 lstr4 into v_text separate by ' '.

CLEAR out_tab.

READ TABLE out_tab WITH KEY name = 'TNAME'.

out_tab-value = v_text

MODIFY out_tab INDEX sy-tabix.

Regards

Nayan Kumar

Former Member
0 Kudos

Hi,

I have used the same code. But still the data is not flowing.

Here is my code.

Please check and revert.

PROGRAM  ZMEDRUCK_SUBP2.
 
FORM fetch_table_data TABLES in_tab STRUCTURE itcsy
                             out_tab STRUCTURE itcsy.
  TABLES EKKO.
 
  DATA: BEGIN OF header OCCURS 0,
          ld_txt1(163),
          ld_txt2(163),
          ld_txt3(163),
        END OF header.
 
  DATA: li_lines LIKE STANDARD TABLE OF tline WITH HEADER LINE,
        ID like THEAD-TDID,
        TNAME LIKE THEAD-TDNAME,
        TDOBJECT like THEAD-TDOBJECT.
 
  DATA  HTEXT LIKE EKKO-EBELN.
  DATA f_lines TYPE P.
*  HTEXT = EKKO-EBELN.
 
  READ TABLE in_tab WITH KEY EKKO-EBELN.
  if sy-subrc = 0.
  TNAME = in_tab-value.
  ENDIF.
 
*TNAME = EKKO-EBELN.
*CONCATENATE EKPO-ebeln EKPO-ebelp INTO v_item_text.
*MOVE v_head_text to HNAME.
 
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    input         = TNAME
 IMPORTING
   OUTPUT        = TNAME
          .
 
 
CALL FUNCTION 'READ_TEXT'
  EXPORTING
*   CLIENT                        = SY-MANDT
    id                            = 'F01'
    language                      = 'E'
    name                          = TNAME
    object                        = 'EKKO'
*   ARCHIVE_HANDLE                = 0
*   LOCAL_CAT                     = ' '
* IMPORTING
*   HEADER                        = TNAME
  tables
    lines                         = li_lines
 EXCEPTIONS
   ID                            = 1
   LANGUAGE                      = 2
   NAME                          = 3
   NOT_FOUND                     = 4
   OBJECT                        = 5
   REFERENCE_CHECK               = 6
*   WRONG_ACCESS_TO_ARCHIVE       = 7
*   OTHERS                        = 8
          .
IF sy-subrc  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
 READ TABLE li_lines INDEX 1.
  IF sy-subrc = 0.
    header-ld_txt1 = li_lines-tdline.
  ENDIF.
 
DESCRIBE TABLE li_lines LINES f_lines.
 
  data: lstr type String,
        lstr1 type string,
        lstr2 type string,
        lstr3 type string,
        lstr4 type string.
 
  read table li_lines index 1.
    lstr = li_lines.
    condense lstr.
    clear li_lines.
 
  read table li_lines index 2.
    lstr1 = li_lines.
    condense lstr.
    clear li_lines.
 
  read table li_lines index 3.
    lstr2 = li_lines.
    condense lstr.
    clear li_lines.
 
  if f_lines GT 3.
    read table li_lines index 4.
    lstr3 = li_lines.
    condense lstr.
    clear li_lines.
 
  read table li_lines index 5.
    lstr4 = li_lines.
    condense lstr.
    clear li_lines.
    endif.
 
 
  DATA: v_text type text.
      CONCATENATE lstr1 lstr2 lstr3 lstr4 into v_text separated by ' '.
      CLEAR out_tab.
 
  READ TABLE out_tab WITH KEY name = 'TNAME'.
    out_tab-value = v_text.
    MODIFY out_tab INDEX sy-tabix.
 
 
 
ENDFORM.


And my script is :

/:PERFORM FETCH_TABLE_DATA IN PROGRAM ZMEDRUCK_SUBP2
/:USING &EKKO-EBELN&
/:CHANGING &TNAME&
/: ENDPERFORM
IL RECEIVED FROM M/S	&TNAME&

Former Member
0 Kudos

Hi,

have you defined TNAME in your sap script?.

Have you debugged and checked if the text is being fetched in subroutine?

Former Member
0 Kudos

Ya I have defined it as,

/: DEFINE &TNAME& = ' '

The problem with debugging is , im working on a client where there is no test data available. To check I have write a code in one client and transport it to another client to check. Hence im feeling it a lot more difficult to manage. Can u pls go through the code and check whether Its correct and how can I manage in this situation.

Thanks in advance.

Former Member
0 Kudos

Hi,

You need to find out what the root cause is.

Is it the text not coming from FM or is it in passing text to script.

Its better if you debug it.

Former Member
0 Kudos

dear expert,

we have created salary slip in smartforms, earlier its setting according to portarit form and due to user requirement we have changed the setting in landscape forms.we are getting the values,but alligment of valus are distorted. please suggest wa to come this issue.

Regards

Pranav Baghel

Sap-Abap

Former Member
0 Kudos

Hi SAP_WIZ,

I debugged the code completely.

The input parameter passed to FM i.e,. TNAME contains 'XXXXXXXXXX' after the read table before passed to FM. If I manually delete that 'XXXXXXXXXX' and give the actual EKKO-EBELN value for ex: '0000001055' its printing the correct value. If I pass the same 'XXXXXXXXXXX' then field is blank.

PLS HELP !

vallamuthu_madheswaran2
Active Contributor
0 Kudos

Hi,

your Declaring the TNAME as local variable. you should declare as a GLOBAL variable.

Thanks & Regards,

Vallamuthu.M

Former Member
0 Kudos

Hi,

1)do you get naything in in_tab?

2)And you are reading by EKKO-EBELN, is it populated ?

3) After readuing data whay are you doing :

TNAME = EKKO-EBELN?

READ TABLE in_tab WITH KEY EKKO-EBELN.
  if sy-subrc = 0.
  TNAME = in_tab-value.
  ENDIF.
 
TNAME = EKKO-EBELN.

Former Member
0 Kudos

Hi,

1. In in_tab TNAME has XXXXXXXXXX.

2. Im reading by EKKO-EBELN, which is not getting populated.

3. After reading, Im passing TNAME to READ_TEXT FM.

If I manually change in TNAME in debugging mode to a PO no. Its properly printing the required output.

vallamuthu_madheswaran2
Active Contributor
0 Kudos

can you declare TNAME as a global variable and check it.

Thanks & Regards,

Vallamuthu Madheswaran

Former Member
0 Kudos

Hi,

Then your problem is:

1)The script isnt passing value to your form for EBELN.

2)EKKO-EBELN isnot populated in teh subroutine pool.

3)You need to just read it_input , to pass EBELN to read_text.

dont repeat tNAME= EKKO-EBELN after that , it doesnt make sense,because that overwrites your value.

4)Debug your script and check if any value is coming in EKKO-EBELN in the script?

EKKO-EBELN wont be populated in the subroutine pool ,as its being called from script.

Former Member
0 Kudos

Thank you so much for your reply.

EKKO-EBELN wont be populated in the subroutine pool ,as its being called from script.

As u have mentioned script is not passing values to the subroutine. I have debugged the program, script is passing only XXXXXXXXXX.

Can u pls explain me the third point briefly.

3)You need to just read it_input , to pass EBELN to read_text.

dont repeat tNAME= EKKO-EBELN after that , it doesnt make sense,because that overwrites your value.

Thanks in advance.

Former Member
0 Kudos
READ TABLE in_tab WITH KEY EKKO-EBELN.
  if sy-subrc = 0.
  TNAME = in_tab-value.
  ENDIF.

*ekko-ebeln isnt populated, so your read statement will always fail.
 
TNAME = EKKO-EBELN.   "remove this.
*you are overwriting the value of TNAME, which you populated through read statement.Then what was the point of assigning it from read statement in teh first place.

just do a read oin in_tab index1.pass the value to tname.

Former Member
0 Kudos

Thanks SAP_WIZ.

Problem solved.

I debugged the program again in a different client and found the solution.

Thank you so much for your help and time.

Full points awarded.

Former Member
0 Kudos

Thanks SAP_WIZ.

Problem solved.

I debugged the program again in a different client and found the solution.

Thank you so much for your help and time.

Full points awarded.

Former Member
0 Kudos

Thanks SAP_WIZ.

Problem solved.

I debugged the program again in a different client and found the solution.

Thank you so much for your help and time.

Full points awarded.

Former Member
0 Kudos

Thanks SAP_WIZ.

Problem solved.

I debugged the program again in a different client and found the solution.

Thank you so much for your help and time.

Full points awarded.

Answers (0)