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: 

PR to PO ...Standard text problem

Former Member
0 Kudos

Hi all,

I am writing one report , which converts the purchasing requistion to purchase order. I am using the BAPI function module...BAPI_PO_CREATE1.

In this i want to populate the purchase order header text. I am using the standard text for all po's whose are convertable.

but the problem is , the header text table paramers(POTEXTHEADER) in BAPI FM will take 132 chars only. But my standard text is 6 paragraphs are there . how do i long text populate? Am i using the wrong parameters in the BAPI FM.

please suggest me ...how to use this BAPI FM , to populate the lonf standard text.

regards,

Ajay Reddy

Edited by: Ajay on May 27, 2008 9:08 AM

5 REPLIES 5

former_member188685
Active Contributor
0 Kudos

but the problem is , the header text table paramers(POTEXTHEADER) in BAPI FM will take 132 chars only. But my standard text is 6 paragraphs are there . how do i long text populate

POTEXTHEADER is the table paramter, so populate the text what ever you have in the potextheader table, with the same text name , id etc...loop your text and populate the text to that table.

0 Kudos

Hi Vijay,

sorry I am using the table parameters POTEXTHEADER.

regards,

Ajay reddy

0 Kudos

Hi Vijay,

can you give me the sample code for this to populate the long standard text to the BAPI.

regards,

Ajay

Former Member
0 Kudos

hi

use the function module create_text to upload long text. below is the

sample program which uploads purchase order text more than 132 characters.

TABLES : MARA, TLINE, THEAD.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR, " MATERIAL NUMBER

TEXT(5000) TYPE C, " Long Text

END OF ITAB.

DATA: BEGIN OF ITAB1 OCCURS 0,

MATNR LIKE MARA-MATNR, " Material No

SEQU TYPE I, " Text Sequence

TEXT(5000) TYPE C, " Long Text

END OF ITAB1.

DATA:BEGIN OF DT_LINES OCCURS 0.

INCLUDE STRUCTURE TLINE. " Long Text

DATA:END OF DT_LINES.

DATA : P_FILE1 TYPE STRING.

DATA : DL_NAME TYPE THEAD-TDNAME, " Object Name(material no)

DL_LAN TYPE THEAD-TDSPRAS. " Language

CONSTANTS:C_BEST TYPE THEAD-TDID VALUE 'BEST',

C_MATERIAL TYPE THEAD-TDOBJECT VALUE 'MATERIAL'. " OBJECT

DATA: START TYPE I,

LEN TYPE I VALUE 92,

TOTLEN TYPE I,

N TYPE I.

SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-101.

PARAMETERS P_FILE LIKE RLGRAP-FILENAME."input file

SELECTION-SCREEN : END OF BLOCK B1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM FETCH_FILE USING P_FILE.

&----


*& Form fetch_file

&----


  • text

----


  • -->P_FILE text

----


FORM FETCH_FILE USING P_FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

IMPORTING

FILE_NAME = P_FILE.

ENDFORM. "fetch_file

START-OF-SELECTION.

PERFORM UPLOAD USING P_FILE. " *To Upload Flat file

PERFORM UPLOAD_TEXT.

&----


*& Form UPLOAD

&----


  • text

----


  • -->P_FILE text

----


FORM UPLOAD USING P_FILE.

P_FILE1 = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = P_FILE1

FILETYPE = 'DAT'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = ITAB

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC EQ 0.

*message i001 with p_file .

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

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

ENDIF.

ENDFORM. "UPLOAD

&----


*& Form UPLOAD_TEXT

&----


  • text

----


FORM UPLOAD_TEXT.

LOOP AT ITAB.

ITAB1-MATNR = ITAB-MATNR.

CLEAR: TOTLEN,N, START.

TOTLEN = STRLEN( ITAB-TEXT ).

N = TOTLEN / LEN.

N = N + 1.

DO N TIMES.

ITAB1-TEXT = ITAB-TEXT+START(LEN).

ITAB1-SEQU = SY-INDEX.

START = START + LEN.

APPEND ITAB1.

ENDDO.

ENDLOOP.

DELETE ITAB1 WHERE TEXT IS INITIAL.

SORT ITAB1 BY MATNR SEQU.

LOOP AT ITAB1.

DT_LINES-TDFORMAT = '*'.

DT_LINES-TDLINE = ITAB1-TEXT.

APPEND DT_LINES.

AT END OF MATNR.

DL_LAN = SY-LANGU.

  • WRITE : / itab-MATNR.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = ITAB1-MATNR

IMPORTING

OUTPUT = ITAB1-MATNR.

MOVE ITAB1-MATNR TO DL_NAME.

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

FID = C_BEST

FLANGUAGE = DL_LAN

FNAME = DL_NAME

FOBJECT = C_MATERIAL

SAVE_DIRECT = 'X'

FFORMAT = '*'

TABLES

FLINES = DT_LINES

EXCEPTIONS

NO_INIT = 1

NO_SAVE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

WRITE:/10 'Long Text Creation failed for Material No', ITAB1-MATNR.

ELSE.

WRITE:/10 'Long Text Created Successfully for Material No', ITAB1-MATNR.

ENDIF.

REFRESH DT_LINES.

ENDAT.

ENDLOOP.

ENDFORM. "UPLOAD_TEXT

Former Member
0 Kudos

Hi Ajay,

Just out of curiosity I would like to know why are you not using sap standard programs that automatically convert PR to PO.

Transaction : ME59 and ME59N.

Regards,

N