Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

I want to condense the gaps

Hello abap gurus,

I need a hepl form u for the FI credit note i have used the following code it is working fine when the long text (when we go through fb03 in that the long text) when the alternate line is kept empty at that time my programing is going in to dump.

I'll show u with an example

1.aaaaaaaaaaaaaaaaaaaaaaaaaaaaa

bbbbbbbbbbbbbbbbbbbbbbbbbbbbb

ccccccccccccccccccccccccccccc

2.qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq

cccccccccccccccccccccccccccccc

3.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

cccccccccccccccccccccccccccccccccc

in 1,2 it is working fine

but for the case 3 it is going in to dump.

please help me out

i need ur help plzzzzzzz as it is very urgent .

please do the need ful. Thanku in advance.

i have alse used the comdense statements

***************************************************************

  • Fetching Data from BKPF AND BSEG Table *

***************************************************************

DATA: V_ID LIKE THEAD-TDID, "TO HOLD Text ID VALUE.

V_NAME LIKE THEAD-TDNAME, "TO HOLD Name

V_OBJECT LIKE THEAD-TDOBJECT, "Texts: Application Object

L_TEXT LIKE THEAD-TDNAME. " NAME FOR THE PARTICUALT ITEM

DATA: V_LANG LIKE THEAD-TDSPRAS.

DATA: IT_LINE LIKE TLINE OCCURS 0 WITH HEADER LINE. "DELCARING SAPscript: Text Lines

data : w_item(6) type C value '000010'.

CONCATENATE P_BELNR w_item INTO L_TEXT.

*V_ID = '0001'.

    • V_NAME = V_ITEMN.

*V_OBJECT = 'VBBP'.

*V_LANG = 'EN'.

***************************************************************

  • Fetching Data from BKPF Table *

***************************************************************

SELECT BELNR "Accounting Document Number

BLART "Document Type

BLDAT "Document Date in Document

BUDAT "Posting Date in the Document

XBLNR "Reference Document Number

  • LIFNR "Different Invoicing Party

BKTXT "Document Header Text

  • SGTXT "ITEM TEXT

KNUMV "Number of the document condition

FROM BKPF

INTO CORRESPONDING FIELDS OF TABLE IT_BKPF

WHERE BELNR = P_BELNR.

IF NOT IT_BKPF[] IS INITIAL.

***************************************************************

  • Fetching Data from BSEG Table *

***************************************************************

SELECT BUKRS "Company Code

BELNR "Accounting Document Number

GJAHR "Fiscal Year

BUZEI "Number of Line Item Within Accounting Document

BSCHL "POSTING KEY

werks "PLANT

SHKZG "Debit/Credit Indicator

SGTXT "Item Text

WRBTR "Amount in document currency

MATNR "Material Number

KUNNR "Customer

LIFNR "Account Number of Vendor or Creditor

FROM BSEG

INTO CORRESPONDING FIELDS OF TABLE IT_BSEG

FOR ALL ENTRIES IN IT_BKPF

WHERE BELNR = IT_BKPF-BELNR

AND BSCHL = '11'.

ENDIF.

IF NOT IT_BSEG[] IS INITIAL.

***************************************************************

  • Fetching Data from KNA1 Table *

***************************************************************

SELECT KUNNR " Customer Number 1

LAND1 "

ADRNR "Address

WERKS

FROM KNA1

INTO TABLE IT_KNA1

FOR ALL ENTRIES IN IT_BSEG

WHERE KUNNR = IT_BSEG-KUNNR

AND SPRAS = 'EN'.

ENDIF.

***************************************************************

  • Fetching Data from T005T Table *

***************************************************************

SELECT LANDX

SPRAS

LAND1

FROM T005T

INTO CORRESPONDING FIELDS OF TABLE IT_T005T

FOR ALL ENTRIES IN IT_KNA1

WHERE SPRAS = 'EN' AND LAND1 = IT_KNA1-LAND1.

****************************************************************

    • Fetching Data from ADRC Table *

****************************************************************

SELECT ADDRNUMBER " Address number

NAME1 " Name 1

NAME2 " Name 2

CITY1 " City

CITY2 " District

POST_CODE1 " City postal code

COUNTRY

FROM ADRC

INTO TABLE IT_ADRC

FOR ALL ENTRIES IN IT_KNA1

WHERE ADDRNUMBER = IT_KNA1-ADRNR.

*ENDIF.

SORT IT_ADRC BY ADDRNUMBER.

*LOOP AT IT_BKPF INTO WA_BKPF.

LOOP AT IT_BSEG INTO WA_BSEG.

****************************************************************

    • Reading Data from RBKP Table *

****************************************************************

*CONCATENATE WA_VBRP-VBELN WA_VBRP-POSNR INTO V_ITEMN.

*

READ TABLE IT_BKPF INTO WA_BKPF WITH KEY BELNR = WA_BSEG-BELNR.

IF SY-SUBRC = 0.

WA_HEADER-BUDAT = WA_BKPF-BUDAT.

IF WA_BSEG-bschl = '11'.

FLAG = 0.

V_TITLE = 'credited'.

WA_HEADER-BELNR = WA_BKPF-BELNR.

WA_HEADER-BUDAT = WA_BKPF-BUDAT.

WA_HEADER-BLDAT = WA_BKPF-BLDAT.

WA_HEADER-XBLNR = WA_BKPF-XBLNR.

ELSE.

FLAG = 1.

V_TITLE = 'debited'.

WA_HEADER-BELNR = WA_BKPf-BELNR.

WA_HEADER-BELNR = WA_BKPF-BELNR.

WA_HEADER-BUDAT = WA_BKPF-BUDAT.

WA_HEADER-BLDAT = WA_BKPF-BLDAT.

WA_HEADER-XBLNR = WA_BKPF-XBLNR.

ENDIF.

ENDIF.

*

****************************************************************

    • Reading Data from KNA1 Table *

****************************************************************

*

READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY kunnr = WA_Bseg-kunnr.

IF SY-SUBRC = 0.

WA_HEADER-KUNNR = WA_KNA1-KUNNR.

ENDIF.

*

****************************************************************

    • Reading Data from T005T Table *

****************************************************************

READ TABLE IT_T005T INTO WA_T005T WITH KEY LAND1 = WA_KNA1-LAND1.

IF SY-SUBRC EQ 0.

TRANSLATE WA_T005T-LANDX TO UPPER CASE.

*WA_HEADER-LANDX = WA_T005T-LANDX.

ENDIF.

*

*

****************************************************************

    • Reading Data from ADRC Table *

****************************************************************

*

READ TABLE IT_ADRC INTO WA_ADRC WITH KEY ADDRNUMBER = WA_KNA1-ADRNR .

IF SY-SUBRC = 0.

WA_HEADER-NAME1 = WA_ADRC-NAME1.

WA_HEADER-NAME2 = WA_ADRC-NAME2.

WA_HEADER-CITY1 = WA_ADRC-CITY1.

WA_HEADER-CITY2 = WA_ADRC-CITY2.

WA_HEADER-POST_CODE1 = WA_ADRC-POST_CODE1.

WA_HEADER-FAX_NUMBER = WA_ADRC-FAX_NUMBER.

**

ENDIF.

*break sealabap01.

IF SY-SUBRC = 0.

*WA_ITEM-MATNR = WA_BSEG-MATNR.

WA_ITEM-SGTXT = WA_BSEG-SGTXT.

WA_ITEM-WRBTR = WA_BSEG-WRBTR.

ENDIF.

**

******************************************************************

      • Logic For the Serial Number *

******************************************************************

V_RUP = V_RUP + WA_BSEG-WRBTR.

V_RUPEE = V_RUP.

CONDENSE V_RUPEE NO-GAPS.

V_RUP = V_RUPEE.

I = I + 1.

WA_ITEM-SRNO = I.

BREAK SEALABAP01.

V_ID = '0001'.

  • V_NAME = V_ITEMN.

V_OBJECT = 'DOC_ITEM'.

V_LANG = 'EN'.

*READ TABLE IT_BSEG INTO WA_BSEG INDEX 1.

IF SY-SUBRC = 0.

*WA_ITEM-L_TEXT = WA_TEXT.

loop at it_bseg into wa_bseg.

wa_header-bukrs = wa_bseg-bukrs.

wa_header-gjahr = wa_bseg-gjahr.

wa_header-buzei = wa_bseg-buzei.

CONCATENATE WA_HEADER-BUKRS P_BELNR WA_HEADER-GJAHR WA_HEADER-BUZEI INTO L_TEXT.

endloop.

ENDIF.

SELECT TDOBJECT

TDNAME

TDID

TDSPRAS

TDTXTLINES

FROM STXH

INTO TABLE IT_TEMP

WHERE TDOBJECT = V_OBJECT

AND TDNAME = L_TEXT

AND TDID = V_ID

AND TDSPRAS = V_LANG.

IF SY-SUBRC = 0.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = V_ID

LANGUAGE = V_LANG

NAME = L_TEXT

OBJECT = V_OBJECT

TABLES

LINES = IT_LINE.

*if sy-subrc = 0.

IT_TEXT[] = IT_LINE[].

*endif.

endif.

*BREAK SEALABAP01.

LOOP AT IT_TEXT INTO WA_TEXT.

wa_ITEM-l_text = wa_text.

CONDENSE WA_ITEM-L_TEXT NO-GAPS.

REPLACE FIRST OCCURENCE OF '*' IN WA_TEXT-TDLINE WITH ' '.

IF SY-SUBRC EQ 0.

CLEAR V_LEN.

V_LEN = STRLEN( WA_TEXT-TDLINE ).

CONCATENATE V_TEXTS WA_TEXT-TDLINE+1(V_LEN) INTO V_TEXTS.

ELSE.

CONCATENATE V_TEXTS WA_TEXT-TDLINE INTO V_TEXTS .

CONDENSE V_TEXTS NO-GAPS.

ENDIF.

*WA_ITEM-TEXTS = V_TEXTS.

APPEND WA_ITEM TO IT_ITEM.

CLEAR: WA_ITEM,

WA_ITEM-SRNO .

**ENDIF.

ENDLOOP.

ENDLOOP.

WA_ITEM-SRNO = SY-TABIX.

*

      • Logic For the Amount in Words *

******************************************************************

*

*

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = V_RUP

CURRENCY = 'INR'

FILLER = ' '

LANGUAGE = SY-LANGU

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question